# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
66652 | 2018-08-12T00:28:51 Z | tincamatei | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 1000 ms | 64692 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 30000; vector<pair<int, int> > graph[MAX_N]; map<pair<int, int>, bool> doges; int dist[MAX_N]; bool inQueue[MAX_N]; int dijkstra(int n, int src, int dest) { int firstDist = 0, cons = 0; deque<deque<int> > pq(n); memset(dist, 0x3f3f3f3f, sizeof(dist)); dist[src] = 0; pq.front().push_back(src); while(cons <= n) { pq.push_back(deque<int>()); if(pq.front().empty()) ++cons; else cons = 0; for(auto nod: pq.front()) { if(firstDist == dist[nod]) { if(nod == dest) return firstDist; for(auto it: graph[nod]) if(firstDist + it.second < dist[it.first]) { dist[it.first] = firstDist + it.second; pq[it.second].push_back(it.first); } } } pq.pop_front(); ++firstDist; } return -1; } int main() { int n, m, b, p, src, dest; scanf("%d%d", &n, &m); for(int i = 0; i < m; ++i) { scanf("%d%d", &b, &p); if(i == 0) src = b; if(i == 1) dest = b; doges[make_pair(b, p)] = true; } for(auto it: doges) { pair<int, int> doge = it.first; if(it.second) { int poz = doge.first - doge.second, cost = 1; bool foundSimilar = false; while(poz >= 0 && !foundSimilar) { graph[doge.first].push_back(make_pair(poz, cost++)); if(doges[make_pair(poz, doge.second)]) foundSimilar = true; poz -= doge.second; } poz = doge.first + doge.second, cost = 1; foundSimilar = false; while(poz < n && !foundSimilar) { graph[doge.first].push_back(make_pair(poz, cost++)); if(doges[make_pair(poz, doge.second)]) foundSimilar = true; poz += doge.second; } } } printf("%d", dijkstra(n, src, dest)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1144 KB | Output is correct |
2 | Correct | 3 ms | 1144 KB | Output is correct |
3 | Correct | 3 ms | 1308 KB | Output is correct |
4 | Correct | 3 ms | 1308 KB | Output is correct |
5 | Correct | 3 ms | 1308 KB | Output is correct |
6 | Correct | 3 ms | 1368 KB | Output is correct |
7 | Correct | 3 ms | 1368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1368 KB | Output is correct |
2 | Correct | 3 ms | 1368 KB | Output is correct |
3 | Correct | 3 ms | 1368 KB | Output is correct |
4 | Correct | 3 ms | 1368 KB | Output is correct |
5 | Correct | 3 ms | 1368 KB | Output is correct |
6 | Correct | 3 ms | 1368 KB | Output is correct |
7 | Correct | 3 ms | 1368 KB | Output is correct |
8 | Correct | 4 ms | 1368 KB | Output is correct |
9 | Correct | 4 ms | 1368 KB | Output is correct |
10 | Correct | 4 ms | 1584 KB | Output is correct |
11 | Correct | 5 ms | 1760 KB | Output is correct |
12 | Correct | 4 ms | 1760 KB | Output is correct |
13 | Correct | 4 ms | 1760 KB | Output is correct |
14 | Correct | 5 ms | 1896 KB | Output is correct |
15 | Correct | 5 ms | 1992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1992 KB | Output is correct |
2 | Correct | 2 ms | 1992 KB | Output is correct |
3 | Correct | 3 ms | 1992 KB | Output is correct |
4 | Correct | 3 ms | 1992 KB | Output is correct |
5 | Correct | 4 ms | 1992 KB | Output is correct |
6 | Correct | 3 ms | 1992 KB | Output is correct |
7 | Correct | 3 ms | 1992 KB | Output is correct |
8 | Correct | 3 ms | 1992 KB | Output is correct |
9 | Correct | 3 ms | 1992 KB | Output is correct |
10 | Correct | 3 ms | 1992 KB | Output is correct |
11 | Correct | 4 ms | 1992 KB | Output is correct |
12 | Correct | 4 ms | 1992 KB | Output is correct |
13 | Correct | 4 ms | 1992 KB | Output is correct |
14 | Correct | 6 ms | 1992 KB | Output is correct |
15 | Correct | 5 ms | 1992 KB | Output is correct |
16 | Correct | 5 ms | 1992 KB | Output is correct |
17 | Correct | 10 ms | 2944 KB | Output is correct |
18 | Correct | 7 ms | 3068 KB | Output is correct |
19 | Correct | 6 ms | 3068 KB | Output is correct |
20 | Correct | 6 ms | 3068 KB | Output is correct |
21 | Correct | 5 ms | 3068 KB | Output is correct |
22 | Correct | 7 ms | 3068 KB | Output is correct |
23 | Correct | 6 ms | 3068 KB | Output is correct |
24 | Correct | 12 ms | 3580 KB | Output is correct |
25 | Correct | 9 ms | 3580 KB | Output is correct |
26 | Correct | 8 ms | 3580 KB | Output is correct |
27 | Correct | 7 ms | 3580 KB | Output is correct |
28 | Correct | 16 ms | 4348 KB | Output is correct |
29 | Correct | 35 ms | 7164 KB | Output is correct |
30 | Correct | 17 ms | 7164 KB | Output is correct |
31 | Correct | 29 ms | 7164 KB | Output is correct |
32 | Correct | 13 ms | 7164 KB | Output is correct |
33 | Correct | 106 ms | 11344 KB | Output is correct |
34 | Correct | 108 ms | 11388 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 11388 KB | Output is correct |
2 | Correct | 3 ms | 11388 KB | Output is correct |
3 | Correct | 3 ms | 11388 KB | Output is correct |
4 | Correct | 3 ms | 11388 KB | Output is correct |
5 | Correct | 3 ms | 11388 KB | Output is correct |
6 | Correct | 3 ms | 11388 KB | Output is correct |
7 | Correct | 2 ms | 11388 KB | Output is correct |
8 | Correct | 3 ms | 11388 KB | Output is correct |
9 | Correct | 3 ms | 11388 KB | Output is correct |
10 | Correct | 3 ms | 11388 KB | Output is correct |
11 | Correct | 5 ms | 11388 KB | Output is correct |
12 | Correct | 5 ms | 11388 KB | Output is correct |
13 | Correct | 4 ms | 11388 KB | Output is correct |
14 | Correct | 6 ms | 11388 KB | Output is correct |
15 | Correct | 6 ms | 11388 KB | Output is correct |
16 | Correct | 5 ms | 11388 KB | Output is correct |
17 | Correct | 12 ms | 11388 KB | Output is correct |
18 | Correct | 9 ms | 11388 KB | Output is correct |
19 | Correct | 7 ms | 11388 KB | Output is correct |
20 | Correct | 6 ms | 11388 KB | Output is correct |
21 | Correct | 4 ms | 11388 KB | Output is correct |
22 | Correct | 6 ms | 11388 KB | Output is correct |
23 | Correct | 6 ms | 11388 KB | Output is correct |
24 | Correct | 11 ms | 11388 KB | Output is correct |
25 | Correct | 8 ms | 11388 KB | Output is correct |
26 | Correct | 7 ms | 11388 KB | Output is correct |
27 | Correct | 8 ms | 11388 KB | Output is correct |
28 | Correct | 22 ms | 11388 KB | Output is correct |
29 | Correct | 41 ms | 11388 KB | Output is correct |
30 | Correct | 12 ms | 11388 KB | Output is correct |
31 | Correct | 22 ms | 11388 KB | Output is correct |
32 | Correct | 18 ms | 11388 KB | Output is correct |
33 | Correct | 82 ms | 11388 KB | Output is correct |
34 | Correct | 95 ms | 11416 KB | Output is correct |
35 | Correct | 81 ms | 11416 KB | Output is correct |
36 | Correct | 12 ms | 11416 KB | Output is correct |
37 | Correct | 154 ms | 15612 KB | Output is correct |
38 | Correct | 159 ms | 15612 KB | Output is correct |
39 | Correct | 156 ms | 15612 KB | Output is correct |
40 | Correct | 151 ms | 15612 KB | Output is correct |
41 | Correct | 144 ms | 15612 KB | Output is correct |
42 | Correct | 14 ms | 15612 KB | Output is correct |
43 | Correct | 21 ms | 15612 KB | Output is correct |
44 | Correct | 19 ms | 15612 KB | Output is correct |
45 | Correct | 601 ms | 36988 KB | Output is correct |
46 | Correct | 569 ms | 37148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 37148 KB | Output is correct |
2 | Correct | 3 ms | 37148 KB | Output is correct |
3 | Correct | 2 ms | 37148 KB | Output is correct |
4 | Correct | 2 ms | 37148 KB | Output is correct |
5 | Correct | 3 ms | 37148 KB | Output is correct |
6 | Correct | 3 ms | 37148 KB | Output is correct |
7 | Correct | 3 ms | 37148 KB | Output is correct |
8 | Correct | 3 ms | 37148 KB | Output is correct |
9 | Correct | 3 ms | 37148 KB | Output is correct |
10 | Correct | 3 ms | 37148 KB | Output is correct |
11 | Correct | 5 ms | 37148 KB | Output is correct |
12 | Correct | 4 ms | 37148 KB | Output is correct |
13 | Correct | 4 ms | 37148 KB | Output is correct |
14 | Correct | 5 ms | 37148 KB | Output is correct |
15 | Correct | 7 ms | 37148 KB | Output is correct |
16 | Correct | 6 ms | 37148 KB | Output is correct |
17 | Correct | 11 ms | 37148 KB | Output is correct |
18 | Correct | 9 ms | 37148 KB | Output is correct |
19 | Correct | 7 ms | 37148 KB | Output is correct |
20 | Correct | 6 ms | 37148 KB | Output is correct |
21 | Correct | 5 ms | 37148 KB | Output is correct |
22 | Correct | 8 ms | 37148 KB | Output is correct |
23 | Correct | 6 ms | 37148 KB | Output is correct |
24 | Correct | 10 ms | 37148 KB | Output is correct |
25 | Correct | 8 ms | 37148 KB | Output is correct |
26 | Correct | 8 ms | 37148 KB | Output is correct |
27 | Correct | 7 ms | 37148 KB | Output is correct |
28 | Correct | 19 ms | 37148 KB | Output is correct |
29 | Correct | 44 ms | 37148 KB | Output is correct |
30 | Correct | 13 ms | 37148 KB | Output is correct |
31 | Correct | 20 ms | 37148 KB | Output is correct |
32 | Correct | 15 ms | 37148 KB | Output is correct |
33 | Correct | 112 ms | 37148 KB | Output is correct |
34 | Correct | 103 ms | 37148 KB | Output is correct |
35 | Correct | 102 ms | 37148 KB | Output is correct |
36 | Correct | 13 ms | 37148 KB | Output is correct |
37 | Correct | 175 ms | 37148 KB | Output is correct |
38 | Correct | 135 ms | 37148 KB | Output is correct |
39 | Correct | 143 ms | 37148 KB | Output is correct |
40 | Correct | 135 ms | 37148 KB | Output is correct |
41 | Correct | 179 ms | 37148 KB | Output is correct |
42 | Correct | 14 ms | 37148 KB | Output is correct |
43 | Correct | 13 ms | 37148 KB | Output is correct |
44 | Correct | 12 ms | 37148 KB | Output is correct |
45 | Correct | 612 ms | 37200 KB | Output is correct |
46 | Correct | 468 ms | 37200 KB | Output is correct |
47 | Execution timed out | 1090 ms | 64692 KB | Time limit exceeded |
48 | Halted | 0 ms | 0 KB | - |