//UVA10048Audiophobia
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 100 + 5;
const int INF = 1000000000;
int G[maxn][maxn];
int main() {
int m, n, q, kase = 0;
while(scanf("%d%d%d", &n, &m, &q) == 3 && n) {
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(i == j) G[i][j] = 0;
else G[i][j] = G[j][i] = INF;//初始化
for(int i = 0; i < m; i++) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
G[a][b] = G[b][a] = c;
}
for(int k = 1; k <= n; k++)
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
G[i][j] = min(G[i][j], max(G[i][k], G[k][j]));
if(kase++) printf("\n");
printf("Case #%d\n", kase);
for(int i = 0; i < q; i++) {
int u, v;
scanf("%d%d", &u, &v);
if(G[u][v] < INF) printf("%d\n", G[u][v]);
else printf("no path\n");
}
}
return 0;
}
/*
7 9 3
1 2 50
1 3 60
2 4 120
2 5 90
3 6 50
4 6 80
4 7 70
5 7 40
6 7 140
1 7
2 6
6 2
7 6 3
1 2 50
1 3 60
2 4 120
3 6 50
4 6 80
5 7 40
7 5
1 7
2 4
0 0 0
*/
UVA10048Audiophobia
最新推荐文章于 2024-04-07 15:27:36 发布