# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
618641 |
2022-08-02T06:23:34 Z |
andrei_boaca |
007 (CEOI14_007) |
C++14 |
|
310 ms |
24912 KB |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
typedef long long ll;
int n,m,s,d,a,b;
vector<int> muchii[200005];
int dist[5][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);
bfs(s,4);
int minim=1e9;
for(int i=1;i<=n;i++)
{
bool good;
if(dist[4][i]<=1)
good=1;
else
{
good=0;
if(dist[1][i]>=dist[1][s])
{
if(dist[2][i]+1>=dist[2][s])
good=1;
}
if(dist[2][i]>=dist[2][s])
{
if(dist[1][i]+1>=dist[1][s])
good=1;
}
if(dist[1][s]==dist[2][s]&&dist[1][i]+1>=dist[1][s]&&dist[2][i]+1>=dist[2][s])
good=1;
}
if(!good)
minim=min(minim,dist[3][i]-2);
}
cout<<max(-1,minim);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4948 KB |
Output is correct |
2 |
Partially correct |
3 ms |
4948 KB |
Partially correct |
3 |
Correct |
4 ms |
5052 KB |
Output is correct |
4 |
Incorrect |
4 ms |
4948 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
6 |
Correct |
3 ms |
4952 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Incorrect |
3 ms |
5036 KB |
Output isn't correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
3 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
5036 KB |
Output is correct |
12 |
Incorrect |
3 ms |
5076 KB |
Output isn't correct |
13 |
Correct |
3 ms |
5044 KB |
Output is correct |
14 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Incorrect |
4 ms |
5076 KB |
Output isn't correct |
17 |
Incorrect |
3 ms |
5076 KB |
Output isn't correct |
18 |
Incorrect |
3 ms |
5076 KB |
Output isn't correct |
19 |
Correct |
3 ms |
5076 KB |
Output is correct |
20 |
Correct |
3 ms |
5076 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5076 KB |
Output is correct |
23 |
Correct |
4 ms |
5076 KB |
Output is correct |
24 |
Incorrect |
4 ms |
5076 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
7360 KB |
Output is correct |
2 |
Incorrect |
37 ms |
8504 KB |
Output isn't correct |
3 |
Correct |
27 ms |
7500 KB |
Output is correct |
4 |
Incorrect |
40 ms |
8632 KB |
Output isn't correct |
5 |
Correct |
27 ms |
7336 KB |
Output is correct |
6 |
Correct |
30 ms |
7628 KB |
Output is correct |
7 |
Correct |
34 ms |
7828 KB |
Output is correct |
8 |
Correct |
35 ms |
7848 KB |
Output is correct |
9 |
Incorrect |
45 ms |
8772 KB |
Output isn't correct |
10 |
Correct |
148 ms |
17280 KB |
Output is correct |
11 |
Incorrect |
62 ms |
10260 KB |
Output isn't correct |
12 |
Correct |
109 ms |
11764 KB |
Output is correct |
13 |
Incorrect |
111 ms |
10816 KB |
Output isn't correct |
14 |
Correct |
54 ms |
9752 KB |
Output is correct |
15 |
Correct |
66 ms |
11804 KB |
Output is correct |
16 |
Correct |
89 ms |
12260 KB |
Output is correct |
17 |
Correct |
61 ms |
11448 KB |
Output is correct |
18 |
Incorrect |
85 ms |
11440 KB |
Output isn't correct |
19 |
Correct |
107 ms |
13844 KB |
Output is correct |
20 |
Incorrect |
310 ms |
19744 KB |
Output isn't correct |
21 |
Incorrect |
99 ms |
14588 KB |
Output isn't correct |
22 |
Correct |
96 ms |
13284 KB |
Output is correct |
23 |
Partially correct |
115 ms |
14424 KB |
Partially correct |
24 |
Correct |
123 ms |
14260 KB |
Output is correct |
25 |
Incorrect |
120 ms |
13784 KB |
Output isn't correct |
26 |
Partially correct |
107 ms |
13356 KB |
Partially correct |
27 |
Correct |
118 ms |
14436 KB |
Output is correct |
28 |
Correct |
120 ms |
14588 KB |
Output is correct |
29 |
Correct |
156 ms |
16292 KB |
Output is correct |
30 |
Incorrect |
209 ms |
20864 KB |
Output isn't correct |
31 |
Incorrect |
133 ms |
16016 KB |
Output isn't correct |
32 |
Correct |
117 ms |
14412 KB |
Output is correct |
33 |
Partially correct |
109 ms |
14804 KB |
Partially correct |
34 |
Incorrect |
128 ms |
15336 KB |
Output isn't correct |
35 |
Incorrect |
99 ms |
14864 KB |
Output isn't correct |
36 |
Incorrect |
130 ms |
15180 KB |
Output isn't correct |
37 |
Correct |
153 ms |
16552 KB |
Output is correct |
38 |
Correct |
140 ms |
16308 KB |
Output is correct |
39 |
Correct |
138 ms |
16304 KB |
Output is correct |
40 |
Incorrect |
176 ms |
19916 KB |
Output isn't correct |
41 |
Correct |
262 ms |
24912 KB |
Output is correct |