-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10048.cpp
35 lines (32 loc) · 927 Bytes
/
10048.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;
int main()
{
int c, s, q, nod[110][110],a, b, dis, t=0;
bool flag = false;
while(scanf("%d %d %d", &c, &s, &q) and c){
for(int i = 1; i <= c; i++){
for(int j = 1; j <= c; j++){
nod[i][j] = 1e9;
}
}
while(s--){
scanf("%d %d %d", &a, &b, &dis);
nod[a][b] = nod[b][a] = dis;
}
for(int k = 1; k <= c; k++){
for(int i = 1; i <= c; i++){
for(int j = 1; j <= c; j++){
nod[i][j] = min(nod[i][j], max(nod[i][k], nod[k][j]));
}
}
}
if(flag)cout << endl;flag = true;
printf("Case #%d\n", ++t);
while(q--){
scanf("%d %d", &a, &b);
if(nod[a][b] != 1e9)printf("%d\n",nod[a][b]);
else printf("no path\n");
}
}return 0;
}