-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10048.cpp
More file actions
62 lines (59 loc) · 843 Bytes
/
10048.cpp
File metadata and controls
62 lines (59 loc) · 843 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
#define mx 99999999
long i,k,w[110][110],u,v,c,q,c1,c2,s,j,d,t=1,fg=0;
long min(long a,long b)
{
if(a<b)
return a;
else return b;
}
long max(long a,long b)
{
if(a>b)
return a;
else return b;
}
int main()
{
while(~scanf("%ld%ld%ld",&c,&s,&q)&&(s||q||c))
{
for(i=1;i<=c;i++)
{
for(j=1;j<=c;j++)
{
if(i==j)
w[i][j]=0;
else
w[i][j]=mx;
}
}
for(i=1;i<=s;i++)
{
scanf("%ld%ld%ld",&c1,&c2,&d);
w[c1][c2]=w[c2][c1]=d;
}
for(k=1;k<=c;k++)
{
for(i=1;i<=c;i++)
{
for(j=1;j<=c;j++)
{
w[i][j]=min(w[i][j],max(w[i][k],w[k][j]));
}
}
}
if(fg)
printf("\n");
fg=1;
printf("Case #%ld\n",t++);
for(i=1;i<=q;i++)
{
scanf("%ld%ld",&u,&v);
if(w[u][v]==mx)
printf("no path\n");
else
printf("%ld\n",w[u][v]);
}
}
return 0;
}