Test instructions: Find the minimum value of the maximum weights for all paths between two points.
Idea: Change the form of Floyd;
Note: Note the initialization problem and the output form of the UVA flower.
The code is as follows:
#include <iostream>#include<cstdio>#include<cstring>#include<string>#include<map>using namespacestd;#defineINF 0x3f3f3fintdp[ the][ the];intMain () {intN,m,q,a,b,w,ca =0; while(cin>>n>>m>>q) {if(n+m+q==0) Break; if(CA! =0) printf ("\ n"); Memset (DP,0x3f,sizeof(DP)); for(inti =0; I < m; i++) {cin>>a>>b>>W; DP[A][B]= Dp[b][a] =W; } for(inti =1; I <= N; i++) {Dp[i][i]=0; } for(intK =1; K <= N; k++) { for(inti =1; I <= N; i++) { for(intj =1; J <= N; J + +) {Dp[i][j]=min (Dp[i][j],max (dp[i][k],dp[k][j)); } }} cout<<"Case #"<<++ca<<Endl; for(inti =0; i < Q; i++) {cin>>a>>C; if(Dp[a][b] >=inf) {cout<<"No path\n"; } Elsecout<<dp[a][b]<<Endl; } } return 0;}
UVA-10048 Audiophobia (Floyd application)