# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
839351 | 2023-08-29T19:23:37 Z | popovicirobert | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 285 ms | 112532 KB |
#include <bits/stdc++.h> using namespace std; constexpr int MAXN = 30'000; constexpr int MAXP = 30'000; bitset<MAXP + 1> visited[MAXN]; struct Node { unsigned short b, p; int dist; }; int main() { #ifdef HOME ifstream cin("input.in"); ofstream cout("output.out"); #endif ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n, m; cin >> n >> m; vector<unsigned short> b(m), p(m); vector<vector<unsigned short>> P(n); for (int i = 0; i < m; i++) { cin >> b[i] >> p[i]; P[b[i]].push_back(p[i]); } deque<Node> Q; Q.push_front({b[0], p[0], 0}); visited[b[0]][p[0]] = true; while (Q.size()) { auto curr = Q.front(); Q.pop_front(); auto Go = [&Q](int b, int p, int dist, bool front) { if (!visited[b][p]) { if (front) { Q.push_front({b, p, dist}); } else { Q.push_back({b, p, dist}); } visited[b][p] = true; } }; if (curr.b == b[1]) { cout << curr.dist << "\n"; return 0; } for (auto p : P[curr.b]) { Go(curr.b, p, curr.dist, true); } if (curr.b >= curr.p) { Go(curr.b - curr.p, curr.p, curr.dist + 1, false); } if (curr.b + curr.p < n) { Go(curr.b + curr.p, curr.p, curr.dist + 1, false); } } cout << -1 << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 224 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 464 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 596 KB | Output is correct |
12 | Correct | 1 ms | 596 KB | Output is correct |
13 | Correct | 1 ms | 724 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 596 KB | Output is correct |
12 | Correct | 2 ms | 596 KB | Output is correct |
13 | Correct | 1 ms | 724 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 2 ms | 3028 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 4 ms | 7764 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 3 ms | 5716 KB | Output is correct |
24 | Correct | 4 ms | 6868 KB | Output is correct |
25 | Correct | 2 ms | 1748 KB | Output is correct |
26 | Correct | 6 ms | 6612 KB | Output is correct |
27 | Correct | 4 ms | 6996 KB | Output is correct |
28 | Correct | 5 ms | 7764 KB | Output is correct |
29 | Correct | 5 ms | 7636 KB | Output is correct |
30 | Correct | 5 ms | 7636 KB | Output is correct |
31 | Correct | 5 ms | 7636 KB | Output is correct |
32 | Correct | 7 ms | 7636 KB | Output is correct |
33 | Correct | 7 ms | 7764 KB | Output is correct |
34 | Correct | 6 ms | 7764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 596 KB | Output is correct |
12 | Correct | 1 ms | 596 KB | Output is correct |
13 | Correct | 1 ms | 724 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 2 ms | 3028 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 6 ms | 7764 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 3 ms | 5716 KB | Output is correct |
24 | Correct | 4 ms | 6868 KB | Output is correct |
25 | Correct | 2 ms | 1748 KB | Output is correct |
26 | Correct | 4 ms | 6612 KB | Output is correct |
27 | Correct | 4 ms | 6996 KB | Output is correct |
28 | Correct | 6 ms | 7764 KB | Output is correct |
29 | Correct | 7 ms | 7636 KB | Output is correct |
30 | Correct | 4 ms | 7636 KB | Output is correct |
31 | Correct | 6 ms | 7636 KB | Output is correct |
32 | Correct | 5 ms | 7636 KB | Output is correct |
33 | Correct | 6 ms | 7764 KB | Output is correct |
34 | Correct | 6 ms | 7764 KB | Output is correct |
35 | Correct | 9 ms | 6100 KB | Output is correct |
36 | Correct | 2 ms | 2004 KB | Output is correct |
37 | Correct | 8 ms | 7892 KB | Output is correct |
38 | Correct | 10 ms | 8276 KB | Output is correct |
39 | Correct | 5 ms | 1620 KB | Output is correct |
40 | Correct | 8 ms | 7124 KB | Output is correct |
41 | Correct | 9 ms | 7892 KB | Output is correct |
42 | Correct | 6 ms | 6996 KB | Output is correct |
43 | Correct | 7 ms | 7380 KB | Output is correct |
44 | Correct | 7 ms | 8148 KB | Output is correct |
45 | Correct | 22 ms | 8292 KB | Output is correct |
46 | Correct | 21 ms | 8268 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 0 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 596 KB | Output is correct |
12 | Correct | 1 ms | 596 KB | Output is correct |
13 | Correct | 1 ms | 724 KB | Output is correct |
14 | Correct | 2 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 716 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 3 ms | 3028 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 4 ms | 7764 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 3 ms | 5716 KB | Output is correct |
24 | Correct | 5 ms | 6868 KB | Output is correct |
25 | Correct | 3 ms | 1748 KB | Output is correct |
26 | Correct | 6 ms | 6612 KB | Output is correct |
27 | Correct | 5 ms | 6996 KB | Output is correct |
28 | Correct | 5 ms | 7764 KB | Output is correct |
29 | Correct | 6 ms | 7636 KB | Output is correct |
30 | Correct | 5 ms | 7636 KB | Output is correct |
31 | Correct | 5 ms | 7636 KB | Output is correct |
32 | Correct | 5 ms | 7760 KB | Output is correct |
33 | Correct | 7 ms | 7764 KB | Output is correct |
34 | Correct | 6 ms | 7764 KB | Output is correct |
35 | Correct | 8 ms | 6100 KB | Output is correct |
36 | Correct | 2 ms | 2004 KB | Output is correct |
37 | Correct | 9 ms | 7892 KB | Output is correct |
38 | Correct | 13 ms | 8404 KB | Output is correct |
39 | Correct | 5 ms | 1620 KB | Output is correct |
40 | Correct | 8 ms | 7124 KB | Output is correct |
41 | Correct | 8 ms | 7892 KB | Output is correct |
42 | Correct | 7 ms | 6996 KB | Output is correct |
43 | Correct | 7 ms | 7384 KB | Output is correct |
44 | Correct | 8 ms | 8148 KB | Output is correct |
45 | Correct | 22 ms | 8268 KB | Output is correct |
46 | Correct | 18 ms | 8296 KB | Output is correct |
47 | Correct | 26 ms | 31792 KB | Output is correct |
48 | Correct | 5 ms | 1744 KB | Output is correct |
49 | Correct | 5 ms | 1620 KB | Output is correct |
50 | Correct | 4 ms | 1492 KB | Output is correct |
51 | Correct | 55 ms | 86860 KB | Output is correct |
52 | Correct | 61 ms | 95140 KB | Output is correct |
53 | Correct | 16 ms | 18900 KB | Output is correct |
54 | Correct | 32 ms | 61144 KB | Output is correct |
55 | Correct | 44 ms | 77808 KB | Output is correct |
56 | Correct | 59 ms | 112344 KB | Output is correct |
57 | Correct | 4 ms | 2644 KB | Output is correct |
58 | Correct | 62 ms | 111520 KB | Output is correct |
59 | Correct | 59 ms | 103964 KB | Output is correct |
60 | Correct | 58 ms | 103760 KB | Output is correct |
61 | Correct | 61 ms | 98760 KB | Output is correct |
62 | Correct | 116 ms | 112532 KB | Output is correct |
63 | Correct | 130 ms | 111712 KB | Output is correct |
64 | Correct | 145 ms | 111688 KB | Output is correct |
65 | Correct | 193 ms | 111820 KB | Output is correct |
66 | Correct | 285 ms | 111848 KB | Output is correct |
67 | Correct | 188 ms | 111752 KB | Output is correct |