# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65038 |
2018-08-06T13:30:58 Z |
bazsi700 |
007 (CEOI14_007) |
C++14 |
|
385 ms |
20756 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;
}
}
}
if(dists[a] == dists[b]) {
cout << max(min(distd[a]-dists[a],distd[b]-dists[b])-1,-1);
} else {
cout << max(min(distd[a]-dists[a],distd[b]-dists[b]),-1);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
4 ms |
620 KB |
Output is correct |
3 |
Partially correct |
3 ms |
636 KB |
Partially correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
3 ms |
636 KB |
Output is correct |
6 |
Partially correct |
2 ms |
636 KB |
Partially correct |
7 |
Partially correct |
3 ms |
736 KB |
Partially correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Partially correct |
3 ms |
736 KB |
Partially correct |
10 |
Correct |
4 ms |
736 KB |
Output is correct |
11 |
Partially correct |
3 ms |
736 KB |
Partially correct |
12 |
Correct |
4 ms |
736 KB |
Output is correct |
13 |
Partially correct |
4 ms |
736 KB |
Partially correct |
14 |
Correct |
2 ms |
736 KB |
Output is correct |
15 |
Partially correct |
3 ms |
736 KB |
Partially correct |
16 |
Correct |
4 ms |
736 KB |
Output is correct |
17 |
Correct |
5 ms |
736 KB |
Output is correct |
18 |
Correct |
3 ms |
736 KB |
Output is correct |
19 |
Partially correct |
3 ms |
736 KB |
Partially correct |
20 |
Partially correct |
3 ms |
772 KB |
Partially correct |
21 |
Correct |
2 ms |
852 KB |
Output is correct |
22 |
Partially correct |
3 ms |
852 KB |
Partially correct |
23 |
Partially correct |
3 ms |
852 KB |
Partially correct |
24 |
Correct |
3 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
26 ms |
3848 KB |
Partially correct |
2 |
Correct |
40 ms |
5608 KB |
Output is correct |
3 |
Partially correct |
41 ms |
5608 KB |
Partially correct |
4 |
Correct |
53 ms |
6932 KB |
Output is correct |
5 |
Correct |
32 ms |
6932 KB |
Output is correct |
6 |
Correct |
30 ms |
6932 KB |
Output is correct |
7 |
Partially correct |
32 ms |
6932 KB |
Partially correct |
8 |
Partially correct |
35 ms |
6932 KB |
Partially correct |
9 |
Correct |
51 ms |
6932 KB |
Output is correct |
10 |
Partially correct |
211 ms |
11984 KB |
Partially correct |
11 |
Correct |
68 ms |
11984 KB |
Output is correct |
12 |
Partially correct |
90 ms |
12492 KB |
Partially correct |
13 |
Correct |
70 ms |
12492 KB |
Output is correct |
14 |
Correct |
69 ms |
12492 KB |
Output is correct |
15 |
Partially correct |
85 ms |
12692 KB |
Partially correct |
16 |
Correct |
88 ms |
13008 KB |
Output is correct |
17 |
Partially correct |
89 ms |
13008 KB |
Partially correct |
18 |
Correct |
87 ms |
13008 KB |
Output is correct |
19 |
Partially correct |
173 ms |
13536 KB |
Partially correct |
20 |
Correct |
309 ms |
16404 KB |
Output is correct |
21 |
Correct |
208 ms |
16404 KB |
Output is correct |
22 |
Partially correct |
148 ms |
16404 KB |
Partially correct |
23 |
Correct |
130 ms |
16404 KB |
Output is correct |
24 |
Partially correct |
153 ms |
16404 KB |
Partially correct |
25 |
Correct |
115 ms |
16404 KB |
Output is correct |
26 |
Correct |
132 ms |
16404 KB |
Output is correct |
27 |
Partially correct |
147 ms |
16404 KB |
Partially correct |
28 |
Partially correct |
194 ms |
16404 KB |
Partially correct |
29 |
Partially correct |
177 ms |
16404 KB |
Partially correct |
30 |
Correct |
311 ms |
17488 KB |
Output is correct |
31 |
Correct |
148 ms |
17488 KB |
Output is correct |
32 |
Partially correct |
267 ms |
17488 KB |
Partially correct |
33 |
Correct |
146 ms |
17488 KB |
Output is correct |
34 |
Correct |
184 ms |
17488 KB |
Output is correct |
35 |
Correct |
133 ms |
17488 KB |
Output is correct |
36 |
Correct |
181 ms |
17488 KB |
Output is correct |
37 |
Correct |
170 ms |
17556 KB |
Output is correct |
38 |
Partially correct |
169 ms |
17556 KB |
Partially correct |
39 |
Partially correct |
193 ms |
17556 KB |
Partially correct |
40 |
Correct |
260 ms |
18708 KB |
Output is correct |
41 |
Partially correct |
385 ms |
20756 KB |
Partially correct |