# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101514 | 2019-03-19T03:30:49 Z | cheeheng | 007 (CEOI14_007) | C++14 | 344 ms | 15736 KB |
#include <bits/stdc++.h> using namespace std; vector<int> AdjList[200005]; int dist[200005]; int main(){ int N, M; int s, d, a, b; scanf("%d%d%d%d%d%d", &N, &M, &s, &d, &a, &b); for(int i = 0; i < M; i ++){ int x, y; scanf("%d%d", &x, &y); AdjList[x].push_back(y); AdjList[y].push_back(x); } memset(dist, -1, sizeof(dist)); queue<int> q; q.push(s); dist[s] = 0; while(!q.empty()){ int u = q.front(); q.pop(); for(int v: AdjList[u]){ if(dist[v] == -1){ dist[v] = dist[u] + 1; q.push(v); } } } int sa = dist[a]; int sb = dist[b]; memset(dist, -1, sizeof(dist)); q = queue<int>(); q.push(d); dist[d] = 0; while(!q.empty()){ int u = q.front(); q.pop(); for(int v: AdjList[u]){ if(dist[v] == -1){ dist[v] = dist[u] + 1; q.push(v); } } } int da = dist[a]; int db = dist[b]; //printf("%d %d %d %d\n", sa, sb, da, db); int resA = min(da-sa, db-sa-1); int resB = min(da-sb-1, da-sb); int res = max(resA, resB); int ans = max(res, -1); if(resA == resB){ ans ++; } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 5760 KB | Output is correct |
2 | Correct | 8 ms | 5840 KB | Output is correct |
3 | Correct | 7 ms | 5760 KB | Output is correct |
4 | Incorrect | 8 ms | 5760 KB | Output isn't correct |
5 | Incorrect | 8 ms | 5760 KB | Output isn't correct |
6 | Correct | 8 ms | 5888 KB | Output is correct |
7 | Correct | 8 ms | 5760 KB | Output is correct |
8 | Incorrect | 8 ms | 5888 KB | Output isn't correct |
9 | Correct | 9 ms | 5888 KB | Output is correct |
10 | Correct | 7 ms | 5760 KB | Output is correct |
11 | Correct | 7 ms | 5760 KB | Output is correct |
12 | Incorrect | 7 ms | 5888 KB | Output isn't correct |
13 | Correct | 8 ms | 5760 KB | Output is correct |
14 | Incorrect | 8 ms | 5888 KB | Output isn't correct |
15 | Correct | 8 ms | 5888 KB | Output is correct |
16 | Incorrect | 8 ms | 5888 KB | Output isn't correct |
17 | Incorrect | 7 ms | 5760 KB | Output isn't correct |
18 | Incorrect | 8 ms | 5760 KB | Output isn't correct |
19 | Correct | 8 ms | 5760 KB | Output is correct |
20 | Correct | 9 ms | 5760 KB | Output is correct |
21 | Incorrect | 9 ms | 5760 KB | Output isn't correct |
22 | Correct | 8 ms | 5760 KB | Output is correct |
23 | Correct | 5 ms | 5760 KB | Output is correct |
24 | Incorrect | 9 ms | 5888 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 7160 KB | Output is correct |
2 | Incorrect | 60 ms | 7644 KB | Output isn't correct |
3 | Correct | 38 ms | 7288 KB | Output is correct |
4 | Incorrect | 64 ms | 7672 KB | Output isn't correct |
5 | Incorrect | 30 ms | 7032 KB | Output isn't correct |
6 | Incorrect | 33 ms | 7160 KB | Output isn't correct |
7 | Correct | 36 ms | 7416 KB | Output is correct |
8 | Correct | 38 ms | 7416 KB | Output is correct |
9 | Incorrect | 58 ms | 7800 KB | Output isn't correct |
10 | Correct | 205 ms | 12024 KB | Output is correct |
11 | Incorrect | 91 ms | 8568 KB | Output isn't correct |
12 | Correct | 102 ms | 9376 KB | Output is correct |
13 | Incorrect | 72 ms | 8824 KB | Output isn't correct |
14 | Incorrect | 63 ms | 8316 KB | Output isn't correct |
15 | Correct | 94 ms | 9592 KB | Output is correct |
16 | Incorrect | 151 ms | 9592 KB | Output isn't correct |
17 | Correct | 95 ms | 9208 KB | Output is correct |
18 | Incorrect | 93 ms | 9188 KB | Output isn't correct |
19 | Correct | 168 ms | 10408 KB | Output is correct |
20 | Incorrect | 269 ms | 13224 KB | Output isn't correct |
21 | Incorrect | 147 ms | 10872 KB | Output isn't correct |
22 | Correct | 120 ms | 10140 KB | Output is correct |
23 | Correct | 166 ms | 10872 KB | Output is correct |
24 | Correct | 149 ms | 10888 KB | Output is correct |
25 | Incorrect | 123 ms | 10492 KB | Output isn't correct |
26 | Correct | 117 ms | 10232 KB | Output is correct |
27 | Correct | 167 ms | 10872 KB | Output is correct |
28 | Correct | 197 ms | 10900 KB | Output is correct |
29 | Correct | 201 ms | 11692 KB | Output is correct |
30 | Incorrect | 282 ms | 13816 KB | Output isn't correct |
31 | Incorrect | 170 ms | 11724 KB | Output isn't correct |
32 | Correct | 152 ms | 10744 KB | Output is correct |
33 | Correct | 137 ms | 10872 KB | Output is correct |
34 | Incorrect | 161 ms | 11256 KB | Output isn't correct |
35 | Incorrect | 190 ms | 11000 KB | Output isn't correct |
36 | Incorrect | 142 ms | 11256 KB | Output isn't correct |
37 | Incorrect | 169 ms | 11896 KB | Output isn't correct |
38 | Correct | 152 ms | 11760 KB | Output is correct |
39 | Correct | 179 ms | 11844 KB | Output is correct |
40 | Incorrect | 268 ms | 13400 KB | Output isn't correct |
41 | Correct | 344 ms | 15736 KB | Output is correct |