Test instructions: Give a C point, s bar Edge composed of the graph, to find a path to the other point of the maximum weight of the least path, output this value
can put this
D[i][j]=min (D[i][j],d[i][k]+d[k][j])
Change to D[i][j]=min (D[i][j],max (D[i][k],d[k][j]))
That is, to find the maximum weight of an edge, and then from these edges to find the smallest
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <stack>6#include <vector>7#include <map>8#include <Set>9#include <queue>Ten#include <algorithm> One #definemod=1e9+7; A using namespacestd; - -typedefLong LongLL; the Const intINF =0x7fffffff; - Const intmaxn= the; - intD[MAXN][MAXN]; - + intMain () { - intN,m,q,i,j,k,kase=0, u,v,w; + while(SCANF (" %d%d%d", &n,&m,&q)!=eof&&n&&m&&q) { A at for(i=1; i<=n;i++){ - for(j=1; j<=n;j++){ - if(I==J) d[i][j]=0; - Elsed[i][j]=INF; - } - } in for(i=1; i<=m;i++){ -scanf" %d%d%d",&u,&v,&W); toD[u][v]=w;//No direction graph, so weights are assigned in all two directions. +d[v][u]=W; - } the * for(k=1; k<=n;k++) $ for(i=1; i<=n;i++)Panax Notoginseng for(j=1; j<=n;j++) -d[i][j]=min (D[i][j],max (d[i][k],d[k][j)); the + if(Kase) printf ("\ n"); Aprintf"Case #%d\n",++Kase); the while(q--){ + intx, y; -scanf"%d%d",&x,&y); $ $ if(D[x][y]!=inf) printf ("%d\n", D[x][y]); - Elseprintf"No path\n"); - } the } - return 0;Wuyi}
View Code
UVa 10048 Audiophobia "Floyd"