# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
666162 |
2022-11-27T16:36:53 Z |
bin9638 |
007 (CEOI14_007) |
C++17 |
|
200 ms |
26060 KB |
#include<bits/stdc++.h>
using namespace std;
#define N 200010
#define ll long long
#define ii pair<int,int>
#define fs first
#define sc second
#define pb push_back
int dp[N][5],f[5],n,m;
vector<int>g[N];
deque<int>dq;
void build(int id)
{
dp[f[id]][id]=0;
dq.pb(f[id]);
while(!dq.empty())
{
int u=dq.front();
dq.pop_front();
for(auto v:g[u])
if(dp[v][id]>dp[u][id]+1)
{
dp[v][id]=dp[u][id]+1;
dq.pb(v);
}
}
}
int main()
{
// freopen("A.inp","r",stdin);
// freopen("A.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m>>f[1]>>f[2]>>f[3]>>f[4];
for(int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
g[u].pb(v);
g[v].pb(u);
}
memset(dp,0x3f3f,sizeof(dp));
for(int i=1;i<=2;i++)
build(i);
int val=min(dp[f[3]][2]-dp[f[3]][1],dp[f[4]][2]-dp[f[4]][1]);
if(val<0)
cout<<-1;
else cout<<val;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8916 KB |
Output is correct |
2 |
Correct |
5 ms |
8916 KB |
Output is correct |
3 |
Correct |
4 ms |
8916 KB |
Output is correct |
4 |
Incorrect |
6 ms |
8916 KB |
Output isn't correct |
5 |
Incorrect |
6 ms |
8872 KB |
Output isn't correct |
6 |
Correct |
5 ms |
8916 KB |
Output is correct |
7 |
Correct |
4 ms |
8916 KB |
Output is correct |
8 |
Incorrect |
5 ms |
8916 KB |
Output isn't correct |
9 |
Correct |
4 ms |
8872 KB |
Output is correct |
10 |
Correct |
4 ms |
8916 KB |
Output is correct |
11 |
Correct |
4 ms |
8916 KB |
Output is correct |
12 |
Incorrect |
4 ms |
8876 KB |
Output isn't correct |
13 |
Correct |
4 ms |
8916 KB |
Output is correct |
14 |
Incorrect |
4 ms |
8916 KB |
Output isn't correct |
15 |
Correct |
4 ms |
8916 KB |
Output is correct |
16 |
Incorrect |
4 ms |
8916 KB |
Output isn't correct |
17 |
Incorrect |
5 ms |
8872 KB |
Output isn't correct |
18 |
Incorrect |
5 ms |
8916 KB |
Output isn't correct |
19 |
Correct |
6 ms |
8916 KB |
Output is correct |
20 |
Correct |
4 ms |
8876 KB |
Output is correct |
21 |
Correct |
6 ms |
8872 KB |
Output is correct |
22 |
Correct |
5 ms |
8876 KB |
Output is correct |
23 |
Correct |
4 ms |
8916 KB |
Output is correct |
24 |
Incorrect |
5 ms |
8916 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
10676 KB |
Output is correct |
2 |
Incorrect |
25 ms |
11464 KB |
Output isn't correct |
3 |
Correct |
24 ms |
10740 KB |
Output is correct |
4 |
Incorrect |
34 ms |
11468 KB |
Output isn't correct |
5 |
Correct |
23 ms |
10532 KB |
Output is correct |
6 |
Correct |
24 ms |
10804 KB |
Output is correct |
7 |
Correct |
21 ms |
10920 KB |
Output is correct |
8 |
Correct |
26 ms |
10996 KB |
Output is correct |
9 |
Incorrect |
30 ms |
11864 KB |
Output isn't correct |
10 |
Correct |
139 ms |
20240 KB |
Output is correct |
11 |
Incorrect |
45 ms |
12840 KB |
Output isn't correct |
12 |
Correct |
67 ms |
13916 KB |
Output is correct |
13 |
Incorrect |
49 ms |
13172 KB |
Output isn't correct |
14 |
Correct |
47 ms |
12344 KB |
Output is correct |
15 |
Correct |
54 ms |
13888 KB |
Output is correct |
16 |
Correct |
57 ms |
14120 KB |
Output is correct |
17 |
Correct |
66 ms |
13620 KB |
Output is correct |
18 |
Incorrect |
67 ms |
13516 KB |
Output isn't correct |
19 |
Correct |
77 ms |
15992 KB |
Output is correct |
20 |
Incorrect |
141 ms |
21732 KB |
Output isn't correct |
21 |
Incorrect |
83 ms |
15944 KB |
Output isn't correct |
22 |
Correct |
71 ms |
15012 KB |
Output is correct |
23 |
Correct |
75 ms |
15788 KB |
Output is correct |
24 |
Correct |
74 ms |
15748 KB |
Output is correct |
25 |
Incorrect |
96 ms |
15336 KB |
Output isn't correct |
26 |
Correct |
95 ms |
15060 KB |
Output is correct |
27 |
Correct |
79 ms |
15900 KB |
Output is correct |
28 |
Correct |
93 ms |
15888 KB |
Output is correct |
29 |
Correct |
94 ms |
18024 KB |
Output is correct |
30 |
Incorrect |
164 ms |
22660 KB |
Output isn't correct |
31 |
Incorrect |
97 ms |
17128 KB |
Output isn't correct |
32 |
Correct |
78 ms |
15816 KB |
Output is correct |
33 |
Correct |
87 ms |
16072 KB |
Output is correct |
34 |
Incorrect |
102 ms |
16592 KB |
Output isn't correct |
35 |
Incorrect |
106 ms |
16164 KB |
Output isn't correct |
36 |
Incorrect |
82 ms |
16384 KB |
Output isn't correct |
37 |
Correct |
99 ms |
17480 KB |
Output is correct |
38 |
Correct |
109 ms |
17220 KB |
Output is correct |
39 |
Correct |
135 ms |
17228 KB |
Output is correct |
40 |
Incorrect |
147 ms |
21128 KB |
Output isn't correct |
41 |
Correct |
200 ms |
26060 KB |
Output is correct |