I know what I'm doing.
Statement:
structedge{intY,v,next;} E[MAXN+ -];intlink[maxn+ -];intlen=0;voidPushintXxintYyintVV) {e[++len].next=link[xx]; link[xx]=len;e[len].v=vv;e[len].y=yy;}intMain () {F (I,1, N) {scanf ("%d%d%d",&xx,&yy,&ZZ); Push (XX,YY,ZZ); Push (YY,XX,ZZ); }}
Transfer package:
void floyed () { f (k,1, N) F ( I,1, N) F (J,1, N) if (Dis[i][k]+dis[k][j]<dis[i][j]) // If there is a bit of k, so that the path of i-->k plus k-->j is shorter than i-->j, the path to update i~j is shorter and is recorded in path Dis[i][j]=dis[i][k]+dis[k][j],path[i][j]=K;}
Single source non-negative shortest path:
voidDijkstraintSt) {F (i,1, N) dis[i]=A[st][i]; memset (Vis,0,sizeof(VIS)); VIS[ST]=1;d is[st]=0; F (i,1, N-1) { intmaxn=INF; intk=0; F (J,1, N) { if((!vis[j]) && (dis[j]<MAXN)) {MAXN=Dis[j]; K=J; } } if(k==0)return; VIS[K]=1; F (J,1, N)//since the outer layer is the I loop, K is replaced by dis (the distance from St to dis[n] so that only one layer of loop can be used to update points with floyed { if(!vis[j]&&[k]+a[k][j]<dis[j])//if the nearest point to the Origin K plus K to J (1~n) is closer (and not accessed) than the St to J distance, the path is updated to a shorter one;dis[j]=dis[k]+A[k][j]; } }}
Basic algorithm of Recheck graph theory