# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
613945 |
2022-07-30T14:09:33 Z |
andrei_boaca |
007 (CEOI14_007) |
C++14 |
|
275 ms |
18340 KB |
#include <bits/stdc++.h>
using namespace std;
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(!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 |
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 |
3 ms |
4948 KB |
Output is correct |
7 |
Partially correct |
3 ms |
5028 KB |
Partially correct |
8 |
Correct |
3 ms |
5028 KB |
Output is correct |
9 |
Partially correct |
3 ms |
5028 KB |
Partially correct |
10 |
Correct |
3 ms |
5028 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
5076 KB |
Output is correct |
13 |
Partially correct |
4 ms |
5076 KB |
Partially correct |
14 |
Correct |
4 ms |
5036 KB |
Output is correct |
15 |
Correct |
3 ms |
5032 KB |
Output is correct |
16 |
Correct |
3 ms |
5032 KB |
Output is correct |
17 |
Correct |
3 ms |
5076 KB |
Output is correct |
18 |
Correct |
3 ms |
5076 KB |
Output is correct |
19 |
Partially correct |
3 ms |
5032 KB |
Partially correct |
20 |
Partially correct |
3 ms |
5076 KB |
Partially correct |
21 |
Correct |
3 ms |
5076 KB |
Output is correct |
22 |
Correct |
3 ms |
5076 KB |
Output is correct |
23 |
Correct |
4 ms |
5036 KB |
Output is correct |
24 |
Correct |
4 ms |
5044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
20 ms |
7280 KB |
Partially correct |
2 |
Correct |
29 ms |
8276 KB |
Output is correct |
3 |
Partially correct |
28 ms |
7372 KB |
Partially correct |
4 |
Correct |
37 ms |
8412 KB |
Output is correct |
5 |
Correct |
22 ms |
7244 KB |
Output is correct |
6 |
Correct |
21 ms |
7472 KB |
Output is correct |
7 |
Correct |
24 ms |
7756 KB |
Output is correct |
8 |
Correct |
25 ms |
7724 KB |
Output is correct |
9 |
Correct |
38 ms |
8268 KB |
Output is correct |
10 |
Partially correct |
154 ms |
12856 KB |
Partially correct |
11 |
Correct |
53 ms |
9912 KB |
Output is correct |
12 |
Partially correct |
72 ms |
11056 KB |
Partially correct |
13 |
Correct |
51 ms |
10292 KB |
Output is correct |
14 |
Correct |
44 ms |
9396 KB |
Output is correct |
15 |
Partially correct |
64 ms |
11244 KB |
Partially correct |
16 |
Correct |
82 ms |
11564 KB |
Output is correct |
17 |
Correct |
78 ms |
10936 KB |
Output is correct |
18 |
Correct |
69 ms |
10920 KB |
Output is correct |
19 |
Partially correct |
99 ms |
12056 KB |
Partially correct |
20 |
Correct |
154 ms |
14904 KB |
Output is correct |
21 |
Correct |
113 ms |
13352 KB |
Output is correct |
22 |
Partially correct |
114 ms |
12288 KB |
Partially correct |
23 |
Partially correct |
94 ms |
13216 KB |
Partially correct |
24 |
Partially correct |
97 ms |
13204 KB |
Partially correct |
25 |
Correct |
98 ms |
12772 KB |
Output is correct |
26 |
Partially correct |
104 ms |
12328 KB |
Partially correct |
27 |
Correct |
96 ms |
13308 KB |
Output is correct |
28 |
Correct |
117 ms |
13264 KB |
Output is correct |
29 |
Partially correct |
114 ms |
13688 KB |
Partially correct |
30 |
Correct |
194 ms |
15808 KB |
Output is correct |
31 |
Correct |
121 ms |
14496 KB |
Output is correct |
32 |
Partially correct |
114 ms |
13172 KB |
Partially correct |
33 |
Partially correct |
121 ms |
13636 KB |
Partially correct |
34 |
Correct |
137 ms |
13792 KB |
Output is correct |
35 |
Correct |
94 ms |
13536 KB |
Output is correct |
36 |
Correct |
101 ms |
13812 KB |
Output is correct |
37 |
Correct |
139 ms |
14952 KB |
Output is correct |
38 |
Correct |
149 ms |
14684 KB |
Output is correct |
39 |
Correct |
142 ms |
14744 KB |
Output is correct |
40 |
Correct |
175 ms |
16204 KB |
Output is correct |
41 |
Partially correct |
275 ms |
18340 KB |
Partially correct |