# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
618645 |
2022-08-02T06:24:20 Z |
andrei_boaca |
007 (CEOI14_007) |
C++14 |
|
218 ms |
17572 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][i]==dist[2][i]&&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 |
2 ms |
4948 KB |
Output is correct |
2 |
Partially correct |
2 ms |
4948 KB |
Partially correct |
3 |
Correct |
2 ms |
5012 KB |
Output is correct |
4 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
5 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
6 |
Correct |
3 ms |
4948 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
9 |
Correct |
2 ms |
4948 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 |
5076 KB |
Output isn't correct |
13 |
Correct |
3 ms |
5076 KB |
Output is correct |
14 |
Incorrect |
3 ms |
4948 KB |
Output isn't correct |
15 |
Correct |
2 ms |
4948 KB |
Output is correct |
16 |
Incorrect |
3 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 |
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 |
6868 KB |
Output is correct |
2 |
Incorrect |
25 ms |
7820 KB |
Output isn't correct |
3 |
Correct |
23 ms |
7036 KB |
Output is correct |
4 |
Incorrect |
27 ms |
7892 KB |
Output isn't correct |
5 |
Correct |
27 ms |
6860 KB |
Output is correct |
6 |
Correct |
20 ms |
7164 KB |
Output is correct |
7 |
Correct |
24 ms |
7264 KB |
Output is correct |
8 |
Correct |
27 ms |
7252 KB |
Output is correct |
9 |
Incorrect |
40 ms |
7776 KB |
Output isn't correct |
10 |
Correct |
127 ms |
12188 KB |
Output is correct |
11 |
Incorrect |
46 ms |
9200 KB |
Output isn't correct |
12 |
Correct |
63 ms |
10440 KB |
Output is correct |
13 |
Incorrect |
50 ms |
9616 KB |
Output isn't correct |
14 |
Correct |
38 ms |
8780 KB |
Output is correct |
15 |
Correct |
58 ms |
10360 KB |
Output is correct |
16 |
Correct |
64 ms |
10704 KB |
Output is correct |
17 |
Correct |
58 ms |
10168 KB |
Output is correct |
18 |
Incorrect |
64 ms |
10096 KB |
Output isn't correct |
19 |
Correct |
95 ms |
11344 KB |
Output is correct |
20 |
Incorrect |
182 ms |
14204 KB |
Output isn't correct |
21 |
Incorrect |
95 ms |
12684 KB |
Output isn't correct |
22 |
Correct |
90 ms |
11552 KB |
Output is correct |
23 |
Partially correct |
95 ms |
12372 KB |
Partially correct |
24 |
Correct |
103 ms |
12336 KB |
Output is correct |
25 |
Incorrect |
96 ms |
12004 KB |
Output isn't correct |
26 |
Partially correct |
93 ms |
11648 KB |
Partially correct |
27 |
Correct |
142 ms |
12536 KB |
Output is correct |
28 |
Correct |
126 ms |
12492 KB |
Output is correct |
29 |
Correct |
148 ms |
12876 KB |
Output is correct |
30 |
Incorrect |
198 ms |
14976 KB |
Output isn't correct |
31 |
Incorrect |
134 ms |
13656 KB |
Output isn't correct |
32 |
Correct |
96 ms |
12372 KB |
Output is correct |
33 |
Partially correct |
101 ms |
12692 KB |
Partially correct |
34 |
Incorrect |
116 ms |
13056 KB |
Output isn't correct |
35 |
Incorrect |
107 ms |
12908 KB |
Output isn't correct |
36 |
Incorrect |
98 ms |
13080 KB |
Output isn't correct |
37 |
Correct |
182 ms |
14080 KB |
Output is correct |
38 |
Correct |
114 ms |
13900 KB |
Output is correct |
39 |
Correct |
183 ms |
13976 KB |
Output is correct |
40 |
Incorrect |
192 ms |
15448 KB |
Output isn't correct |
41 |
Correct |
218 ms |
17572 KB |
Output is correct |