This question is about selecting the maximum load path from 1 to n and finding the maximum load.
To obtain the maximum load, we need to find the minimum load that each route can carry.
You can use Dijkstra algorithm to find
Assume that the current maximum load before is d [x] And now the route W [x] [Y] is used to reach y.
We will compare and classify d [X] and W [x] [Y] To get d [Y].
#include<stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<algorithm>#include<queue>#include<stack>#define mem(a,b) memset(a,b,sizeof(a))#define ll __int64#define MAXN 1000#define INF 0x7ffffff#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1using namespace std;int w[1200][1200];int d[1200];int v[1200];int main(){ int t,n,m,cas=1; int i,j; int a,b,c; cin>>t; while(t--) { printf("Scenario #%d:\n",cas++); cin>>n>>m; mem(w,0); mem(v,0); while(m--) { scanf("%d%d%d",&a,&b,&c); w[a][b]=w[b][a]=c; } for(int i=1;i<=n;i++) d[i]=(i==1?INF:0); for(i=1;i<=n;i++) { int x,maxx=0; for(int y=1;y<=n;y++) if(!v[y]&&d[y]>=maxx) maxx=d[x=y]; v[x]=1; for(int y=1;y<=n;y++) { if(d[x]>=w[x][y]&&w[x][y]>d[y]) { d[y]=w[x][y]; } else if(d[x]<w[x][y]&&d[x]>d[y]) { d[y]=d[x]; } } } cout<<d[n]<<endl<<endl; } return 0;}