# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
613865 |
2022-07-30T12:13:27 Z |
andrei_boaca |
007 (CEOI14_007) |
C++14 |
|
219 ms |
17596 KB |
#include <bits/stdc++.h>
using namespace std;
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[1][i]>=dist[1][s]&&dist[2][i]>=dist[2][s])||dist[4][i]<=1)
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 |
Partially correct |
3 ms |
4948 KB |
Partially correct |
2 |
Partially correct |
2 ms |
4948 KB |
Partially correct |
3 |
Partially correct |
3 ms |
4948 KB |
Partially correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
4948 KB |
Output is correct |
6 |
Correct |
2 ms |
4948 KB |
Output is correct |
7 |
Partially correct |
4 ms |
4948 KB |
Partially correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Partially correct |
3 ms |
4948 KB |
Partially correct |
10 |
Partially correct |
4 ms |
4948 KB |
Partially correct |
11 |
Partially correct |
3 ms |
4948 KB |
Partially correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Partially correct |
3 ms |
5076 KB |
Partially correct |
14 |
Correct |
2 ms |
4948 KB |
Output is correct |
15 |
Partially correct |
3 ms |
4948 KB |
Partially correct |
16 |
Correct |
3 ms |
5028 KB |
Output is correct |
17 |
Correct |
3 ms |
5076 KB |
Output is correct |
18 |
Correct |
4 ms |
5084 KB |
Output is correct |
19 |
Partially correct |
3 ms |
5076 KB |
Partially correct |
20 |
Partially correct |
3 ms |
5076 KB |
Partially correct |
21 |
Partially correct |
3 ms |
5076 KB |
Partially correct |
22 |
Partially correct |
3 ms |
5076 KB |
Partially correct |
23 |
Correct |
3 ms |
5076 KB |
Output is correct |
24 |
Correct |
3 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
24 ms |
6944 KB |
Partially correct |
2 |
Correct |
28 ms |
7736 KB |
Output is correct |
3 |
Partially correct |
27 ms |
7064 KB |
Partially correct |
4 |
Correct |
27 ms |
7856 KB |
Output is correct |
5 |
Partially correct |
22 ms |
6836 KB |
Partially correct |
6 |
Partially correct |
22 ms |
7080 KB |
Partially correct |
7 |
Partially correct |
24 ms |
7296 KB |
Partially correct |
8 |
Partially correct |
26 ms |
7300 KB |
Partially correct |
9 |
Correct |
35 ms |
7760 KB |
Output is correct |
10 |
Partially correct |
123 ms |
12084 KB |
Partially correct |
11 |
Correct |
51 ms |
9292 KB |
Output is correct |
12 |
Partially correct |
66 ms |
10300 KB |
Partially correct |
13 |
Correct |
48 ms |
9564 KB |
Output is correct |
14 |
Correct |
40 ms |
8864 KB |
Output is correct |
15 |
Partially correct |
59 ms |
10444 KB |
Partially correct |
16 |
Partially correct |
71 ms |
10724 KB |
Partially correct |
17 |
Partially correct |
69 ms |
10068 KB |
Partially correct |
18 |
Correct |
67 ms |
10156 KB |
Output is correct |
19 |
Partially correct |
104 ms |
11268 KB |
Partially correct |
20 |
Correct |
157 ms |
14136 KB |
Output is correct |
21 |
Correct |
120 ms |
12532 KB |
Output is correct |
22 |
Partially correct |
98 ms |
11448 KB |
Partially correct |
23 |
Partially correct |
103 ms |
12352 KB |
Partially correct |
24 |
Partially correct |
90 ms |
12364 KB |
Partially correct |
25 |
Correct |
80 ms |
11980 KB |
Output is correct |
26 |
Partially correct |
112 ms |
11588 KB |
Partially correct |
27 |
Partially correct |
92 ms |
12524 KB |
Partially correct |
28 |
Partially correct |
125 ms |
12572 KB |
Partially correct |
29 |
Partially correct |
136 ms |
13004 KB |
Partially correct |
30 |
Correct |
167 ms |
14976 KB |
Output is correct |
31 |
Correct |
142 ms |
13664 KB |
Output is correct |
32 |
Partially correct |
94 ms |
12380 KB |
Partially correct |
33 |
Partially correct |
124 ms |
12724 KB |
Partially correct |
34 |
Correct |
146 ms |
13068 KB |
Output is correct |
35 |
Correct |
93 ms |
12724 KB |
Output is correct |
36 |
Correct |
98 ms |
13108 KB |
Output is correct |
37 |
Partially correct |
152 ms |
14156 KB |
Partially correct |
38 |
Partially correct |
129 ms |
13896 KB |
Partially correct |
39 |
Partially correct |
142 ms |
13884 KB |
Partially correct |
40 |
Correct |
169 ms |
15444 KB |
Output is correct |
41 |
Partially correct |
219 ms |
17596 KB |
Partially correct |