-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11463.cpp
More file actions
executable file
·54 lines (52 loc) · 1.22 KB
/
11463.cpp
File metadata and controls
executable file
·54 lines (52 loc) · 1.22 KB
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
#include <bits/stdc++.h>
using namespace std;
int INF=1000000;
int main()
{
// freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int T;
cin>>T;
int ct=1;
while(T--)
{
int n;
cin>>n;
int start[n][n],end[n][n];
for(int i=0; i<n;i++)
{
for(int j=0; j<n; j++)
{
if(i!=j)
{start[i][j]=INF;
end[i][j]=INF;}
else start[i][j]=0,end[i][j]=0;
}
}
int r; cin>>r;
int aa,bb;
for(int i=0; i<r; i++)
{
cin>>aa>>bb;
start[aa][bb]=1;
start[bb][aa]=1;
end[aa][bb]=1;
end[bb][aa]=1;
}
int src,dest;
cin>>src>>dest;
for(int k=0; k<n; k++)
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
{
start[i][j]=min(start[i][j],start[i][k]+start[k][j]);
end[i][j]=min(end[i][j],end[i][k]+end[k][j]);
}
int MAX=-1;
for(int i=0; i<n; i++)
{
MAX=max(MAX,start[src][i]+end[i][dest]);
}
cout<<"Case "<<ct++<<": "<<MAX<<endl;
}
}