# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
787919 | 2023-07-19T14:26:50 Z | floralfield | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 588 ms | 3732 KB |
/* Solution to APIO '15 P2 - Jakarta Skyscrapers by Ava Pun Key concepts: graph theory, Dijkstra's */ #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int INF = 0x3F3F3F3F; const int MAX = 3e4 + 5; int N, M, A, B; vector<int> arr[MAX]; int dist[MAX]; bool vis[MAX]; int dijk() { fill(dist, dist + N + 1, INF); priority_queue< pii, vector<pii>, greater<pii> > pq; dist[A] = 0; pq.push({dist[A], A}); while (!pq.empty()) { pii x = pq.top(); pq.pop(); int u = x.second; if (!vis[u]) { vis[u] = true; for (int i : arr[u]) { int v; for (int j = 1; u + (i * j) < N; j++) { v = u + (i * j); if (dist[u] + j < dist[v]) { dist[v] = dist[u] + j; pq.push({dist[v], v}); } } for (int j = -1; u + (i * j) >= 0; j--) { v = u + (i * j); if (dist[u] + abs(j) < dist[v]) { dist[v] = dist[u] + abs(j); pq.push({dist[v], v}); } } } } } return dist[B]; } int main() { scanf("%d%d", &N, &M); int a, b; for (int i = 0; i < M; i++) { scanf("%d%d", &a, &b); arr[a].push_back(b); if (i == 0) { A = a; } else if (i == 1) { B = a; } } int ans = dijk(); printf("%d", ans == INF ? -1 : ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 980 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 980 KB | Output is correct |
11 | Correct | 1 ms | 980 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 980 KB | Output is correct |
15 | Correct | 1 ms | 980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 1000 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 980 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 980 KB | Output is correct |
11 | Correct | 1 ms | 980 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 932 KB | Output is correct |
14 | Correct | 1 ms | 980 KB | Output is correct |
15 | Correct | 1 ms | 980 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
18 | Correct | 1 ms | 980 KB | Output is correct |
19 | Correct | 1 ms | 980 KB | Output is correct |
20 | Correct | 3 ms | 1108 KB | Output is correct |
21 | Correct | 1 ms | 1156 KB | Output is correct |
22 | Correct | 1 ms | 980 KB | Output is correct |
23 | Correct | 1 ms | 980 KB | Output is correct |
24 | Correct | 1 ms | 980 KB | Output is correct |
25 | Correct | 1 ms | 1108 KB | Output is correct |
26 | Correct | 3 ms | 980 KB | Output is correct |
27 | Correct | 3 ms | 980 KB | Output is correct |
28 | Correct | 1 ms | 980 KB | Output is correct |
29 | Correct | 2 ms | 1236 KB | Output is correct |
30 | Correct | 1 ms | 1108 KB | Output is correct |
31 | Correct | 1 ms | 1148 KB | Output is correct |
32 | Correct | 1 ms | 1108 KB | Output is correct |
33 | Correct | 2 ms | 1236 KB | Output is correct |
34 | Correct | 2 ms | 1236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 980 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 980 KB | Output is correct |
11 | Correct | 1 ms | 980 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 1028 KB | Output is correct |
15 | Correct | 1 ms | 980 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
18 | Correct | 1 ms | 980 KB | Output is correct |
19 | Correct | 1 ms | 980 KB | Output is correct |
20 | Correct | 4 ms | 1108 KB | Output is correct |
21 | Correct | 1 ms | 980 KB | Output is correct |
22 | Correct | 1 ms | 980 KB | Output is correct |
23 | Correct | 1 ms | 980 KB | Output is correct |
24 | Correct | 1 ms | 980 KB | Output is correct |
25 | Correct | 1 ms | 1108 KB | Output is correct |
26 | Correct | 4 ms | 980 KB | Output is correct |
27 | Correct | 3 ms | 980 KB | Output is correct |
28 | Correct | 2 ms | 980 KB | Output is correct |
29 | Correct | 2 ms | 1236 KB | Output is correct |
30 | Correct | 1 ms | 1108 KB | Output is correct |
31 | Correct | 1 ms | 1108 KB | Output is correct |
32 | Correct | 1 ms | 1108 KB | Output is correct |
33 | Correct | 2 ms | 1236 KB | Output is correct |
34 | Correct | 3 ms | 1236 KB | Output is correct |
35 | Correct | 5 ms | 1236 KB | Output is correct |
36 | Correct | 2 ms | 980 KB | Output is correct |
37 | Correct | 5 ms | 1300 KB | Output is correct |
38 | Correct | 6 ms | 1364 KB | Output is correct |
39 | Correct | 6 ms | 1364 KB | Output is correct |
40 | Correct | 7 ms | 1364 KB | Output is correct |
41 | Correct | 7 ms | 1364 KB | Output is correct |
42 | Correct | 38 ms | 1236 KB | Output is correct |
43 | Correct | 40 ms | 1236 KB | Output is correct |
44 | Correct | 37 ms | 1236 KB | Output is correct |
45 | Correct | 6 ms | 1364 KB | Output is correct |
46 | Correct | 6 ms | 1364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 980 KB | Output is correct |
8 | Correct | 1 ms | 980 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 980 KB | Output is correct |
11 | Correct | 1 ms | 980 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 980 KB | Output is correct |
15 | Correct | 1 ms | 980 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
18 | Correct | 1 ms | 980 KB | Output is correct |
19 | Correct | 1 ms | 980 KB | Output is correct |
20 | Correct | 3 ms | 1108 KB | Output is correct |
21 | Correct | 1 ms | 980 KB | Output is correct |
22 | Correct | 1 ms | 980 KB | Output is correct |
23 | Correct | 1 ms | 980 KB | Output is correct |
24 | Correct | 1 ms | 980 KB | Output is correct |
25 | Correct | 1 ms | 1108 KB | Output is correct |
26 | Correct | 4 ms | 980 KB | Output is correct |
27 | Correct | 3 ms | 980 KB | Output is correct |
28 | Correct | 1 ms | 980 KB | Output is correct |
29 | Correct | 2 ms | 1236 KB | Output is correct |
30 | Correct | 1 ms | 1108 KB | Output is correct |
31 | Correct | 2 ms | 1108 KB | Output is correct |
32 | Correct | 1 ms | 1108 KB | Output is correct |
33 | Correct | 2 ms | 1236 KB | Output is correct |
34 | Correct | 3 ms | 1236 KB | Output is correct |
35 | Correct | 5 ms | 1236 KB | Output is correct |
36 | Correct | 2 ms | 980 KB | Output is correct |
37 | Correct | 5 ms | 1316 KB | Output is correct |
38 | Correct | 6 ms | 1364 KB | Output is correct |
39 | Correct | 6 ms | 1364 KB | Output is correct |
40 | Correct | 7 ms | 1368 KB | Output is correct |
41 | Correct | 7 ms | 1364 KB | Output is correct |
42 | Correct | 40 ms | 1236 KB | Output is correct |
43 | Correct | 42 ms | 1236 KB | Output is correct |
44 | Correct | 39 ms | 1236 KB | Output is correct |
45 | Correct | 6 ms | 1364 KB | Output is correct |
46 | Correct | 6 ms | 1364 KB | Output is correct |
47 | Correct | 16 ms | 2060 KB | Output is correct |
48 | Correct | 5 ms | 1772 KB | Output is correct |
49 | Correct | 5 ms | 1720 KB | Output is correct |
50 | Correct | 5 ms | 1620 KB | Output is correct |
51 | Correct | 23 ms | 3164 KB | Output is correct |
52 | Correct | 19 ms | 2628 KB | Output is correct |
53 | Correct | 12 ms | 2692 KB | Output is correct |
54 | Correct | 2 ms | 1408 KB | Output is correct |
55 | Correct | 2 ms | 1364 KB | Output is correct |
56 | Correct | 536 ms | 2644 KB | Output is correct |
57 | Correct | 43 ms | 3408 KB | Output is correct |
58 | Correct | 588 ms | 1636 KB | Output is correct |
59 | Correct | 537 ms | 1748 KB | Output is correct |
60 | Correct | 560 ms | 1668 KB | Output is correct |
61 | Correct | 456 ms | 1780 KB | Output is correct |
62 | Correct | 8 ms | 2388 KB | Output is correct |
63 | Correct | 23 ms | 2792 KB | Output is correct |
64 | Correct | 25 ms | 3672 KB | Output is correct |
65 | Correct | 29 ms | 3732 KB | Output is correct |
66 | Correct | 50 ms | 3700 KB | Output is correct |
67 | Correct | 42 ms | 3692 KB | Output is correct |