Ojld @ 2023-10-26 20:21:02
#include <iostream>
#include <cstring>
using namespace std;
const int N = 210 ;
int dist[N][N];
int n , m , k,cnt;
void floyd(){
for(int k = 1 ; k <= n ; k++){
for(int i = 1 ;i <= n ;i ++){
for(int j = 1 ;j <= n ;j ++){
dist[i][j] = min (dist[i][j] ,max( dist[i][k] , dist[k][j]));
}
}
}
}
int main(){
while(cin>>n>>m>>k && n && m && k){
memset(dist, 0x3f , sizeof dist);
for(int i = 1 ;i <= n ; i++)dist[i][i] = 0;
while(m--){
int a , b ,c ;
cin>>a>>b>>c;
dist[a][b] = min(dist[a][b] ,c);
dist[b][a] = min(dist[b][a] , c);
}
floyd();
cout<<"case #"<<++cnt;
while(k--){
int a , b ;
cin>>a>>b;
if(dist[a][b] > 0x3f3f3f3f / 2) cout<<"no path"<<endl;
else cout<<dist[a][b]<<endl;
}
cout<<endl;
}
}
by Ojld @ 2023-10-26 20:21:30
为什么过不了a
by mesan @ 2023-10-26 22:51:20
@Ojld case 的 c 要大写。
by Ojld @ 2023-10-30 20:11:08
@mesan 还是不行大佬
by mesan @ 2023-11-04 12:01:34
@Ojld 输出case后面换行啊