# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65034 |
2018-08-06T13:19:14 Z |
bazsi700 |
007 (CEOI14_007) |
C++14 |
|
402 ms |
26716 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,m,s,d,a,b;
cin >> n >> m >> s >> d >> a >> b;
vector<vector<int> > graph(n+1,vector<int>());
for(int i = 0; i < m; i++) {
int x,y;
cin >> x >> y;
graph[x].push_back(y);
graph[y].push_back(x);
}
vector<bool> wass(n+1,false);
vector<int> dists(n+1,0);
vector<bool> wasd(n+1,false);
vector<int> distd(n+1,0);
wass[s] = true;
queue<int> q;
q.push(s);
while(!q.empty()) {
int v = q.front();
q.pop();
for(int u : graph[v]) {
if(!wass[u]) {
wass[u] = true;
q.push(u);
dists[u] = dists[v]+1;
}
}
}
wasd[d] = true;
q.push(d);
while(!q.empty()) {
int v = q.front();
q.pop();
for(int u : graph[v]) {
if(!wasd[u]) {
wasd[u] = true;
q.push(u);
distd[u] = distd[v]+1;
}
}
}
cout << max(min(distd[a]-dists[a],distd[b]-dists[b])-1,-1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
256 KB |
Partially correct |
2 |
Partially correct |
2 ms |
384 KB |
Partially correct |
3 |
Partially correct |
2 ms |
440 KB |
Partially correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
508 KB |
Output is correct |
6 |
Partially correct |
3 ms |
588 KB |
Partially correct |
7 |
Partially correct |
2 ms |
592 KB |
Partially correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Partially correct |
3 ms |
600 KB |
Partially correct |
10 |
Partially correct |
2 ms |
604 KB |
Partially correct |
11 |
Partially correct |
3 ms |
632 KB |
Partially correct |
12 |
Correct |
2 ms |
676 KB |
Output is correct |
13 |
Partially correct |
4 ms |
676 KB |
Partially correct |
14 |
Correct |
3 ms |
680 KB |
Output is correct |
15 |
Partially correct |
3 ms |
684 KB |
Partially correct |
16 |
Correct |
3 ms |
688 KB |
Output is correct |
17 |
Correct |
3 ms |
712 KB |
Output is correct |
18 |
Correct |
3 ms |
712 KB |
Output is correct |
19 |
Partially correct |
3 ms |
712 KB |
Partially correct |
20 |
Partially correct |
3 ms |
728 KB |
Partially correct |
21 |
Partially correct |
2 ms |
736 KB |
Partially correct |
22 |
Partially correct |
3 ms |
736 KB |
Partially correct |
23 |
Partially correct |
4 ms |
752 KB |
Partially correct |
24 |
Correct |
4 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
53 ms |
3956 KB |
Partially correct |
2 |
Correct |
52 ms |
5596 KB |
Output is correct |
3 |
Partially correct |
37 ms |
5596 KB |
Partially correct |
4 |
Correct |
53 ms |
6920 KB |
Output is correct |
5 |
Partially correct |
37 ms |
6920 KB |
Partially correct |
6 |
Partially correct |
31 ms |
6920 KB |
Partially correct |
7 |
Partially correct |
32 ms |
7720 KB |
Partially correct |
8 |
Partially correct |
32 ms |
8296 KB |
Partially correct |
9 |
Correct |
68 ms |
9704 KB |
Output is correct |
10 |
Partially correct |
218 ms |
18976 KB |
Partially correct |
11 |
Correct |
79 ms |
18976 KB |
Output is correct |
12 |
Partially correct |
108 ms |
18976 KB |
Partially correct |
13 |
Correct |
91 ms |
18976 KB |
Output is correct |
14 |
Correct |
56 ms |
18976 KB |
Output is correct |
15 |
Partially correct |
112 ms |
18976 KB |
Partially correct |
16 |
Partially correct |
134 ms |
19008 KB |
Partially correct |
17 |
Partially correct |
75 ms |
19008 KB |
Partially correct |
18 |
Correct |
84 ms |
19008 KB |
Output is correct |
19 |
Partially correct |
158 ms |
19436 KB |
Partially correct |
20 |
Correct |
251 ms |
22320 KB |
Output is correct |
21 |
Correct |
119 ms |
22320 KB |
Output is correct |
22 |
Partially correct |
103 ms |
22320 KB |
Partially correct |
23 |
Partially correct |
137 ms |
22320 KB |
Partially correct |
24 |
Partially correct |
120 ms |
22320 KB |
Partially correct |
25 |
Correct |
109 ms |
22320 KB |
Output is correct |
26 |
Partially correct |
109 ms |
22320 KB |
Partially correct |
27 |
Partially correct |
130 ms |
22320 KB |
Partially correct |
28 |
Partially correct |
132 ms |
22320 KB |
Partially correct |
29 |
Partially correct |
166 ms |
22320 KB |
Partially correct |
30 |
Correct |
260 ms |
23248 KB |
Output is correct |
31 |
Correct |
149 ms |
23248 KB |
Output is correct |
32 |
Partially correct |
127 ms |
23248 KB |
Partially correct |
33 |
Partially correct |
125 ms |
23248 KB |
Partially correct |
34 |
Correct |
138 ms |
23248 KB |
Output is correct |
35 |
Correct |
141 ms |
23248 KB |
Output is correct |
36 |
Correct |
125 ms |
23248 KB |
Output is correct |
37 |
Partially correct |
200 ms |
23472 KB |
Partially correct |
38 |
Partially correct |
164 ms |
23472 KB |
Partially correct |
39 |
Partially correct |
228 ms |
23472 KB |
Partially correct |
40 |
Correct |
241 ms |
24700 KB |
Output is correct |
41 |
Partially correct |
402 ms |
26716 KB |
Partially correct |