[计蒜客]百度地图的实时路况

您所在的位置:网站首页 实时路况的地图 [计蒜客]百度地图的实时路况

[计蒜客]百度地图的实时路况

2024-07-07 05:32| 来源: 网络整理| 查看: 265

description

给出有向图的点数\(n\)和邻接矩阵\(G\), 求\[P=∑_{1≤x,y,z≤n,x≠y,y≠z}d(x,y,z)\] 其中\(d(x,y,z)\)表示从\(x\)不经过\(y\)到\(z\)的最短路,如果无法到达则为\(-1\)

data range

\[4≤n≤300,−1≤G_{i,j}≤10000,G_{i,i}=0\]

solution

首先你要知道\(floyed\)的本质是枚举中转点。

那么不经过\(y\)点的最短路矩阵相当于使用除\(y\)以外的点作为中转点更新后的邻接矩阵

于是考虑分治,递归到\(l==r\)时仅有节点\(l\)未被作为中转点 那么在做到\([l,r]\)时,使用\([l,mid]\)更新\([mid+1,r]\),使用\([mid+1,r]\)更新\([l,mid]\)即可。

Code #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define Cpy(x,y) memcpy(x,y,sizeof(x)) #define Set(x,y) memset(x,y,sizeof(x)) #define FILE "a" #define mp make_pair #define pb push_back #define RG register #define il inline using namespace std; typedef unsigned long long ull; typedef vectorVI; typedef long long ll; typedef double dd; const int N=200010; const int M=1000010; const dd eps=1e-5; const int inf=2147483647; const ll INF=1ll


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3