# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65951 | 2018-08-09T06:57:20 Z | ikura355 | 007 (CEOI14_007) | C++14 | 469 ms | 102880 KB |
#include<bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int inf = 1e9; struct node { int u,val; node(int _u = 0, int _val = 0) { u = _u; val = _val; } bool operator < (node a) const { return a.val<val; } }; int n,m,a,b,s1,s2; vector<int> way[maxn]; int len[maxn]; priority_queue<node> heap; int d1[maxn], d2[maxn]; int sssp(int u) { for(int i=1;i<=n;i++) len[i] = inf; len[u] = 0; heap.push(node(u,0)); while(!heap.empty()) { auto t = heap.top(); heap.pop(); int u = t.u, val = t.val; if(len[u]!=val) continue; for(auto v : way[u]) { if(len[v] > len[u] + 1) { len[v] = len[u] + 1; heap.push(node(v,len[v])); } } } } int main() { scanf("%d%d",&n,&m); scanf("%d%d%d%d",&a,&b,&s1,&s2); for(int i=1;i<=m;i++) { int u,v; scanf("%d%d",&u,&v); way[u].push_back(v); way[v].push_back(u); } sssp(a); for(int i=1;i<=n;i++) d1[i] = len[i]; sssp(b); for(int i=1;i<=n;i++) d2[i] = len[i]; if(d2[s1]<d1[s1] || d2[s2]<d1[s2]) printf("-1"); else printf("%d",min(d2[s1]-d1[s1], d2[s2]-d1[s2])); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 5052 KB | Output is correct |
2 | Correct | 8 ms | 5100 KB | Output is correct |
3 | Correct | 8 ms | 5100 KB | Output is correct |
4 | Incorrect | 7 ms | 5284 KB | Output isn't correct |
5 | Incorrect | 7 ms | 5284 KB | Output isn't correct |
6 | Correct | 6 ms | 5288 KB | Output is correct |
7 | Correct | 9 ms | 5320 KB | Output is correct |
8 | Incorrect | 7 ms | 5320 KB | Output isn't correct |
9 | Correct | 8 ms | 5384 KB | Output is correct |
10 | Correct | 7 ms | 5384 KB | Output is correct |
11 | Correct | 7 ms | 5384 KB | Output is correct |
12 | Incorrect | 6 ms | 5452 KB | Output isn't correct |
13 | Correct | 6 ms | 5452 KB | Output is correct |
14 | Incorrect | 6 ms | 5452 KB | Output isn't correct |
15 | Correct | 7 ms | 5452 KB | Output is correct |
16 | Incorrect | 7 ms | 5516 KB | Output isn't correct |
17 | Incorrect | 7 ms | 5540 KB | Output isn't correct |
18 | Incorrect | 7 ms | 5564 KB | Output isn't correct |
19 | Correct | 7 ms | 5572 KB | Output is correct |
20 | Correct | 8 ms | 5596 KB | Output is correct |
21 | Correct | 8 ms | 5596 KB | Output is correct |
22 | Correct | 7 ms | 5612 KB | Output is correct |
23 | Correct | 7 ms | 5636 KB | Output is correct |
24 | Incorrect | 8 ms | 5644 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 7820 KB | Output is correct |
2 | Incorrect | 78 ms | 9288 KB | Output isn't correct |
3 | Correct | 47 ms | 9288 KB | Output is correct |
4 | Incorrect | 49 ms | 10540 KB | Output isn't correct |
5 | Correct | 55 ms | 10540 KB | Output is correct |
6 | Correct | 44 ms | 10952 KB | Output is correct |
7 | Correct | 58 ms | 11592 KB | Output is correct |
8 | Correct | 54 ms | 12152 KB | Output is correct |
9 | Incorrect | 70 ms | 13744 KB | Output isn't correct |
10 | Correct | 227 ms | 23148 KB | Output is correct |
11 | Incorrect | 110 ms | 23148 KB | Output isn't correct |
12 | Correct | 150 ms | 23788 KB | Output is correct |
13 | Incorrect | 113 ms | 24292 KB | Output isn't correct |
14 | Correct | 86 ms | 24716 KB | Output is correct |
15 | Correct | 116 ms | 27348 KB | Output is correct |
16 | Correct | 139 ms | 29140 KB | Output is correct |
17 | Correct | 121 ms | 29972 KB | Output is correct |
18 | Incorrect | 144 ms | 31344 KB | Output isn't correct |
19 | Correct | 163 ms | 34972 KB | Output is correct |
20 | Incorrect | 309 ms | 43284 KB | Output isn't correct |
21 | Incorrect | 146 ms | 43476 KB | Output isn't correct |
22 | Correct | 171 ms | 44248 KB | Output is correct |
23 | Correct | 148 ms | 47040 KB | Output is correct |
24 | Correct | 139 ms | 48932 KB | Output is correct |
25 | Incorrect | 153 ms | 50412 KB | Output isn't correct |
26 | Correct | 146 ms | 51996 KB | Output is correct |
27 | Correct | 185 ms | 54556 KB | Output is correct |
28 | Correct | 223 ms | 56616 KB | Output is correct |
29 | Correct | 231 ms | 60636 KB | Output is correct |
30 | Incorrect | 347 ms | 68452 KB | Output isn't correct |
31 | Incorrect | 224 ms | 69204 KB | Output isn't correct |
32 | Correct | 227 ms | 70004 KB | Output is correct |
33 | Correct | 195 ms | 72416 KB | Output is correct |
34 | Incorrect | 250 ms | 74988 KB | Output isn't correct |
35 | Incorrect | 165 ms | 76696 KB | Output isn't correct |
36 | Incorrect | 168 ms | 79140 KB | Output isn't correct |
37 | Correct | 242 ms | 82536 KB | Output is correct |
38 | Correct | 232 ms | 84784 KB | Output is correct |
39 | Correct | 313 ms | 87180 KB | Output is correct |
40 | Incorrect | 355 ms | 93364 KB | Output isn't correct |
41 | Correct | 469 ms | 102880 KB | Output is correct |