Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
68130 王籽易 最爱的城市 C++ 通过 100 0 MS 264 KB 669 2023-02-02 15:42:50

Tests(1/1):


#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; }


测评信息: