# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45444 | 2018-04-14T05:38:49 Z | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 708 ms | 262144 KB |
#include <stdio.h> #include <vector> #include <queue> #define INF 1000000007 int B[30005], P[30005]; std::vector<std::pair<int, int> > AdjList[30005]; int abs(int a) { return (a < 0)?-a:a; } int Min[30005]; typedef struct node node; struct node { int u, w; }; bool operator<(node a, node b) { return (a.w > b.w); } std::priority_queue<node> Q; int main() { int N, M; scanf("%d %d", &N, &M); int i, j; for (i = 0; i < M; i++) scanf("%d %d", &B[i], &P[i]); for (i = 0; i < M; i++) { for (j = 0; j < N; j++) { if (B[i] == j) continue; if (abs(B[i] - j)%P[i] == 0) AdjList[B[i]].push_back({j, abs(B[i] - j)/P[i]}); } } for (i = 0; i < N; i++) { Min[i] = INF; } Min[B[0]] = 0; Q.push({B[0], 0}); node p; int v, w, s; while (!Q.empty()) { do { p = Q.top(); Q.pop(); } while (Min[p.u] < p.w); if (p.u == B[1]) { printf("%d", p.w); return 0; } s = AdjList[p.u].size(); for (i = 0; i < s; i++) { v = AdjList[p.u][i].first; w = AdjList[p.u][i].second; if (p.w + w < Min[v]) { Min[v] = p.w + w; Q.push({v, Min[v]}); } } } printf("-1"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1016 KB | Output is correct |
2 | Correct | 2 ms | 1016 KB | Output is correct |
3 | Correct | 3 ms | 1204 KB | Output is correct |
4 | Correct | 2 ms | 1204 KB | Output is correct |
5 | Correct | 2 ms | 1204 KB | Output is correct |
6 | Correct | 3 ms | 1204 KB | Output is correct |
7 | Correct | 2 ms | 1404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1404 KB | Output is correct |
2 | Correct | 2 ms | 1404 KB | Output is correct |
3 | Correct | 3 ms | 1404 KB | Output is correct |
4 | Correct | 2 ms | 1404 KB | Output is correct |
5 | Correct | 2 ms | 1404 KB | Output is correct |
6 | Correct | 2 ms | 1404 KB | Output is correct |
7 | Correct | 3 ms | 1404 KB | Output is correct |
8 | Correct | 2 ms | 1404 KB | Output is correct |
9 | Correct | 3 ms | 1404 KB | Output is correct |
10 | Correct | 3 ms | 1404 KB | Output is correct |
11 | Correct | 4 ms | 1404 KB | Output is correct |
12 | Correct | 7 ms | 3436 KB | Output is correct |
13 | Correct | 7 ms | 3436 KB | Output is correct |
14 | Correct | 5 ms | 3436 KB | Output is correct |
15 | Correct | 4 ms | 3436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3436 KB | Output is correct |
2 | Correct | 2 ms | 3436 KB | Output is correct |
3 | Correct | 2 ms | 3436 KB | Output is correct |
4 | Correct | 2 ms | 3436 KB | Output is correct |
5 | Correct | 2 ms | 3436 KB | Output is correct |
6 | Correct | 2 ms | 3436 KB | Output is correct |
7 | Correct | 2 ms | 3436 KB | Output is correct |
8 | Correct | 2 ms | 3436 KB | Output is correct |
9 | Correct | 2 ms | 3436 KB | Output is correct |
10 | Correct | 3 ms | 3436 KB | Output is correct |
11 | Correct | 4 ms | 3436 KB | Output is correct |
12 | Correct | 8 ms | 3436 KB | Output is correct |
13 | Correct | 8 ms | 3440 KB | Output is correct |
14 | Correct | 4 ms | 3440 KB | Output is correct |
15 | Correct | 4 ms | 3440 KB | Output is correct |
16 | Correct | 3 ms | 3440 KB | Output is correct |
17 | Correct | 9 ms | 3440 KB | Output is correct |
18 | Correct | 10 ms | 3440 KB | Output is correct |
19 | Correct | 7 ms | 3440 KB | Output is correct |
20 | Correct | 85 ms | 33404 KB | Output is correct |
21 | Correct | 5 ms | 33404 KB | Output is correct |
22 | Correct | 11 ms | 33404 KB | Output is correct |
23 | Correct | 10 ms | 33404 KB | Output is correct |
24 | Correct | 20 ms | 33404 KB | Output is correct |
25 | Correct | 24 ms | 33404 KB | Output is correct |
26 | Correct | 81 ms | 34620 KB | Output is correct |
27 | Correct | 78 ms | 34620 KB | Output is correct |
28 | Correct | 21 ms | 34620 KB | Output is correct |
29 | Correct | 12 ms | 34620 KB | Output is correct |
30 | Correct | 5 ms | 34620 KB | Output is correct |
31 | Correct | 9 ms | 34620 KB | Output is correct |
32 | Correct | 9 ms | 34620 KB | Output is correct |
33 | Correct | 33 ms | 34620 KB | Output is correct |
34 | Correct | 28 ms | 34620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 34620 KB | Output is correct |
2 | Correct | 3 ms | 34620 KB | Output is correct |
3 | Correct | 2 ms | 34620 KB | Output is correct |
4 | Correct | 2 ms | 34620 KB | Output is correct |
5 | Correct | 2 ms | 34620 KB | Output is correct |
6 | Correct | 2 ms | 34620 KB | Output is correct |
7 | Correct | 2 ms | 34620 KB | Output is correct |
8 | Correct | 2 ms | 34620 KB | Output is correct |
9 | Correct | 2 ms | 34620 KB | Output is correct |
10 | Correct | 3 ms | 34620 KB | Output is correct |
11 | Correct | 4 ms | 34620 KB | Output is correct |
12 | Correct | 7 ms | 34620 KB | Output is correct |
13 | Correct | 7 ms | 34620 KB | Output is correct |
14 | Correct | 4 ms | 34620 KB | Output is correct |
15 | Correct | 5 ms | 34620 KB | Output is correct |
16 | Correct | 3 ms | 34620 KB | Output is correct |
17 | Correct | 14 ms | 34620 KB | Output is correct |
18 | Correct | 16 ms | 34620 KB | Output is correct |
19 | Correct | 8 ms | 34620 KB | Output is correct |
20 | Correct | 83 ms | 34620 KB | Output is correct |
21 | Correct | 5 ms | 34620 KB | Output is correct |
22 | Correct | 8 ms | 34620 KB | Output is correct |
23 | Correct | 10 ms | 34620 KB | Output is correct |
24 | Correct | 27 ms | 34620 KB | Output is correct |
25 | Correct | 30 ms | 34620 KB | Output is correct |
26 | Correct | 82 ms | 34620 KB | Output is correct |
27 | Correct | 84 ms | 34620 KB | Output is correct |
28 | Correct | 22 ms | 34620 KB | Output is correct |
29 | Correct | 11 ms | 34620 KB | Output is correct |
30 | Correct | 6 ms | 34620 KB | Output is correct |
31 | Correct | 11 ms | 34620 KB | Output is correct |
32 | Correct | 9 ms | 34620 KB | Output is correct |
33 | Correct | 24 ms | 34620 KB | Output is correct |
34 | Correct | 23 ms | 34620 KB | Output is correct |
35 | Correct | 224 ms | 34620 KB | Output is correct |
36 | Correct | 27 ms | 34620 KB | Output is correct |
37 | Correct | 185 ms | 34620 KB | Output is correct |
38 | Correct | 284 ms | 34620 KB | Output is correct |
39 | Correct | 317 ms | 34620 KB | Output is correct |
40 | Correct | 290 ms | 34620 KB | Output is correct |
41 | Correct | 286 ms | 34620 KB | Output is correct |
42 | Runtime error | 708 ms | 262144 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
43 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 262144 KB | Output is correct |
2 | Correct | 3 ms | 262144 KB | Output is correct |
3 | Correct | 2 ms | 262144 KB | Output is correct |
4 | Correct | 2 ms | 262144 KB | Output is correct |
5 | Correct | 2 ms | 262144 KB | Output is correct |
6 | Correct | 2 ms | 262144 KB | Output is correct |
7 | Correct | 3 ms | 262144 KB | Output is correct |
8 | Correct | 2 ms | 262144 KB | Output is correct |
9 | Correct | 2 ms | 262144 KB | Output is correct |
10 | Correct | 3 ms | 262144 KB | Output is correct |
11 | Correct | 4 ms | 262144 KB | Output is correct |
12 | Correct | 7 ms | 262144 KB | Output is correct |
13 | Correct | 8 ms | 262144 KB | Output is correct |
14 | Correct | 4 ms | 262144 KB | Output is correct |
15 | Correct | 4 ms | 262144 KB | Output is correct |
16 | Correct | 4 ms | 262144 KB | Output is correct |
17 | Correct | 14 ms | 262144 KB | Output is correct |
18 | Correct | 11 ms | 262144 KB | Output is correct |
19 | Correct | 8 ms | 262144 KB | Output is correct |
20 | Correct | 82 ms | 262144 KB | Output is correct |
21 | Correct | 6 ms | 262144 KB | Output is correct |
22 | Correct | 11 ms | 262144 KB | Output is correct |
23 | Correct | 10 ms | 262144 KB | Output is correct |
24 | Correct | 20 ms | 262144 KB | Output is correct |
25 | Correct | 22 ms | 262144 KB | Output is correct |
26 | Correct | 106 ms | 262144 KB | Output is correct |
27 | Correct | 84 ms | 262144 KB | Output is correct |
28 | Correct | 32 ms | 262144 KB | Output is correct |
29 | Correct | 13 ms | 262144 KB | Output is correct |
30 | Correct | 6 ms | 262144 KB | Output is correct |
31 | Correct | 9 ms | 262144 KB | Output is correct |
32 | Correct | 9 ms | 262144 KB | Output is correct |
33 | Correct | 31 ms | 262144 KB | Output is correct |
34 | Correct | 24 ms | 262144 KB | Output is correct |
35 | Correct | 201 ms | 262144 KB | Output is correct |
36 | Correct | 30 ms | 262144 KB | Output is correct |
37 | Correct | 213 ms | 262144 KB | Output is correct |
38 | Correct | 318 ms | 262144 KB | Output is correct |
39 | Correct | 337 ms | 262144 KB | Output is correct |
40 | Correct | 365 ms | 262144 KB | Output is correct |
41 | Correct | 297 ms | 262144 KB | Output is correct |
42 | Runtime error | 588 ms | 262144 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
43 | Halted | 0 ms | 0 KB | - |