# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
613795 |
2022-07-30T11:09:54 Z |
andrei_boaca |
007 (CEOI14_007) |
C++14 |
|
212 ms |
24212 KB |
#include <bits/stdc++.h>
using namespace std;
int n,m,s,d,a,b;
vector<int> muchii[200005];
int dist[4][200005];
void bfs(int start,int index)
{
for(int i=1;i<=n;i++)
dist[index][i]=1e9;
dist[index][start]=0;
queue<int> coada;
coada.push(start);
while(!coada.empty())
{
int nod=coada.front();
coada.pop();
for(int i:muchii[nod])
if(dist[index][i]>dist[index][nod]+1)
{
dist[index][i]=dist[index][nod]+1;
coada.push(i);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>s>>d>>a>>b;
for(int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
muchii[x].push_back(y);
muchii[y].push_back(x);
}
bfs(a,1);
bfs(b,2);
bfs(d,3);
int minim=1e9;
for(int i=1;i<=n;i++)
{
bool good;
if(dist[1][i]+1>=dist[1][s]&&dist[2][i]+1>=dist[2][s])
good=1;
else
good=0;
if(!good)
minim=min(minim,dist[3][i]-2);
}
cout<<max(-1,minim);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
5032 KB |
Output is correct |
4 |
Incorrect |
3 ms |
5028 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
5032 KB |
Output isn't correct |
6 |
Correct |
3 ms |
4948 KB |
Output is correct |
7 |
Correct |
3 ms |
5024 KB |
Output is correct |
8 |
Incorrect |
4 ms |
4948 KB |
Output isn't correct |
9 |
Correct |
3 ms |
5028 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
13 |
Correct |
3 ms |
5076 KB |
Output is correct |
14 |
Incorrect |
2 ms |
4948 KB |
Output isn't correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Incorrect |
3 ms |
5032 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
5032 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
5076 KB |
Output isn't correct |
19 |
Correct |
3 ms |
5032 KB |
Output is correct |
20 |
Correct |
3 ms |
5036 KB |
Output is correct |
21 |
Correct |
3 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5076 KB |
Output is correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Incorrect |
3 ms |
5076 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
7212 KB |
Output is correct |
2 |
Incorrect |
25 ms |
8160 KB |
Output isn't correct |
3 |
Correct |
20 ms |
7412 KB |
Output is correct |
4 |
Incorrect |
26 ms |
8408 KB |
Output isn't correct |
5 |
Correct |
19 ms |
7124 KB |
Output is correct |
6 |
Correct |
19 ms |
7368 KB |
Output is correct |
7 |
Correct |
21 ms |
7632 KB |
Output is correct |
8 |
Correct |
21 ms |
7716 KB |
Output is correct |
9 |
Incorrect |
33 ms |
8556 KB |
Output isn't correct |
10 |
Correct |
114 ms |
17148 KB |
Output is correct |
11 |
Incorrect |
42 ms |
10116 KB |
Output isn't correct |
12 |
Correct |
68 ms |
11320 KB |
Output is correct |
13 |
Incorrect |
45 ms |
10316 KB |
Output isn't correct |
14 |
Correct |
39 ms |
9420 KB |
Output is correct |
15 |
Correct |
67 ms |
11332 KB |
Output is correct |
16 |
Correct |
57 ms |
11676 KB |
Output is correct |
17 |
Correct |
56 ms |
11108 KB |
Output is correct |
18 |
Incorrect |
51 ms |
10956 KB |
Output isn't correct |
19 |
Correct |
79 ms |
13396 KB |
Output is correct |
20 |
Incorrect |
140 ms |
19272 KB |
Output isn't correct |
21 |
Incorrect |
75 ms |
13864 KB |
Output isn't correct |
22 |
Correct |
77 ms |
12620 KB |
Output is correct |
23 |
Correct |
74 ms |
13704 KB |
Output is correct |
24 |
Correct |
96 ms |
13628 KB |
Output is correct |
25 |
Incorrect |
80 ms |
13144 KB |
Output isn't correct |
26 |
Correct |
69 ms |
12820 KB |
Output is correct |
27 |
Correct |
89 ms |
13856 KB |
Output is correct |
28 |
Correct |
88 ms |
13816 KB |
Output is correct |
29 |
Correct |
107 ms |
15644 KB |
Output is correct |
30 |
Incorrect |
158 ms |
20324 KB |
Output isn't correct |
31 |
Incorrect |
98 ms |
15184 KB |
Output isn't correct |
32 |
Correct |
95 ms |
13872 KB |
Output is correct |
33 |
Correct |
84 ms |
14140 KB |
Output is correct |
34 |
Incorrect |
98 ms |
14604 KB |
Output isn't correct |
35 |
Incorrect |
89 ms |
14212 KB |
Output isn't correct |
36 |
Incorrect |
81 ms |
14500 KB |
Output isn't correct |
37 |
Correct |
120 ms |
16020 KB |
Output is correct |
38 |
Correct |
110 ms |
15600 KB |
Output is correct |
39 |
Correct |
116 ms |
15564 KB |
Output is correct |
40 |
Incorrect |
145 ms |
19192 KB |
Output isn't correct |
41 |
Correct |
212 ms |
24212 KB |
Output is correct |