代码如下: #include<bits/stdc++.h> using namespace std; const int N=1e6+7; int n,m,top,x[N],y[N],z[N],dis[N],head[N]; bool vis[N]; struct node{ int too,next,zh; }edge[N]; void add(int a,int b,int c) { edge[++top].too=b;edge[top].zh=c; edge[top].next=head[a];head[a]=top; } void spfa() { ...