| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 68131 | 王籽易 | 最爱的城市 | C++ | Accepted | 100 | 0 MS | 264 KB | 669 | 2023-02-02 15:42:55 |
#include<bits/stdc++.h> using namespace std; int dist[201][201],m,n,u,v; int main(){ while(cin>>n>>m){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==j) dist[i][j]=0; else dist[i][j]=0x3f3f3f3f; } } for(int i=1;i<=m;i++){ int a,b,wi; cin>>a>>b>>wi; dist[a][b]=wi; dist[b][a]=wi; } for(int t=1;t<=n;t++){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(j!=i&&t!=i&&t!=j){ dist[i][j]=min(dist[i][j],dist[i][t]+dist[t][j]); } } } } cin>>u>>v; if(dist[u][v]>0x3f3f3f3f-100000000) cout<<"No path"; else cout<<dist[u][v]; cout<<endl; } return 0; }