# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153066 | 2019-09-12T05:59:13 Z | songc | Jakarta Skyscrapers (APIO15_skyscraper) | C++14 | 1000 ms | 70828 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> pii; int N, M, S, E; set<int> chk[30303]; vector<int> V[30303]; int D[30303]; priority_queue<pii, vector<pii>, greater<pii>> PQ; int main(){ scanf("%d %d", &N, &M); for (int i=1; i<=M; i++){ int x, y; scanf("%d %d", &x, &y); if (i == 1) S = x; if (i == 2) E = x; V[x].push_back(y); } memset(D, -1, sizeof D); PQ.push(pii(0, S)); while (!PQ.empty()){ int x, d; tie(d,x) = PQ.top(); PQ.pop(); if (D[x] != -1) continue; D[x] = d; for (int v : V[x]){ for (int i=1; x-v*i>=0; i++){ if (chk[x-v*i].find(v) != chk[x-v*i].end()) break; chk[x-v*i].insert(v); PQ.push(pii(d+i, x-v*i)); } for (int i=1; x+v*i<N; i++){ if (chk[x+v*i].find(v) != chk[x+v*i].end()) break; chk[x+v*i].insert(v); PQ.push(pii(d+i, x+v*i)); } } } printf("%d\n", D[E]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2552 KB | Output is correct |
2 | Correct | 4 ms | 2552 KB | Output is correct |
3 | Correct | 4 ms | 2552 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 4 ms | 2552 KB | Output is correct |
6 | Correct | 4 ms | 2556 KB | Output is correct |
7 | Correct | 4 ms | 2552 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2552 KB | Output is correct |
2 | Correct | 4 ms | 2552 KB | Output is correct |
3 | Correct | 4 ms | 2552 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 4 ms | 2552 KB | Output is correct |
6 | Correct | 5 ms | 2552 KB | Output is correct |
7 | Correct | 4 ms | 2552 KB | Output is correct |
8 | Correct | 4 ms | 2556 KB | Output is correct |
9 | Correct | 4 ms | 2684 KB | Output is correct |
10 | Correct | 5 ms | 2552 KB | Output is correct |
11 | Correct | 6 ms | 2808 KB | Output is correct |
12 | Correct | 5 ms | 2680 KB | Output is correct |
13 | Correct | 4 ms | 2684 KB | Output is correct |
14 | Correct | 6 ms | 2808 KB | Output is correct |
15 | Correct | 6 ms | 2936 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2556 KB | Output is correct |
2 | Correct | 4 ms | 2552 KB | Output is correct |
3 | Correct | 4 ms | 2552 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 4 ms | 2552 KB | Output is correct |
6 | Correct | 4 ms | 2552 KB | Output is correct |
7 | Correct | 4 ms | 2556 KB | Output is correct |
8 | Correct | 4 ms | 2552 KB | Output is correct |
9 | Correct | 4 ms | 2552 KB | Output is correct |
10 | Correct | 4 ms | 2552 KB | Output is correct |
11 | Correct | 7 ms | 2680 KB | Output is correct |
12 | Correct | 5 ms | 2680 KB | Output is correct |
13 | Correct | 5 ms | 2552 KB | Output is correct |
14 | Correct | 7 ms | 2808 KB | Output is correct |
15 | Correct | 7 ms | 2808 KB | Output is correct |
16 | Correct | 4 ms | 2552 KB | Output is correct |
17 | Correct | 10 ms | 3292 KB | Output is correct |
18 | Correct | 5 ms | 2680 KB | Output is correct |
19 | Correct | 4 ms | 2500 KB | Output is correct |
20 | Correct | 5 ms | 2680 KB | Output is correct |
21 | Correct | 5 ms | 2552 KB | Output is correct |
22 | Correct | 4 ms | 2680 KB | Output is correct |
23 | Correct | 7 ms | 2936 KB | Output is correct |
24 | Correct | 9 ms | 3152 KB | Output is correct |
25 | Correct | 8 ms | 2936 KB | Output is correct |
26 | Correct | 8 ms | 2936 KB | Output is correct |
27 | Correct | 7 ms | 2936 KB | Output is correct |
28 | Correct | 11 ms | 3576 KB | Output is correct |
29 | Correct | 38 ms | 5876 KB | Output is correct |
30 | Correct | 10 ms | 3448 KB | Output is correct |
31 | Correct | 19 ms | 4216 KB | Output is correct |
32 | Correct | 13 ms | 3704 KB | Output is correct |
33 | Correct | 72 ms | 9136 KB | Output is correct |
34 | Correct | 71 ms | 9064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2552 KB | Output is correct |
2 | Correct | 4 ms | 2552 KB | Output is correct |
3 | Correct | 4 ms | 2552 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 4 ms | 2552 KB | Output is correct |
6 | Correct | 4 ms | 2552 KB | Output is correct |
7 | Correct | 4 ms | 2552 KB | Output is correct |
8 | Correct | 4 ms | 2552 KB | Output is correct |
9 | Correct | 4 ms | 2552 KB | Output is correct |
10 | Correct | 4 ms | 2556 KB | Output is correct |
11 | Correct | 6 ms | 2812 KB | Output is correct |
12 | Correct | 5 ms | 2552 KB | Output is correct |
13 | Correct | 4 ms | 2552 KB | Output is correct |
14 | Correct | 6 ms | 2808 KB | Output is correct |
15 | Correct | 6 ms | 2808 KB | Output is correct |
16 | Correct | 4 ms | 2552 KB | Output is correct |
17 | Correct | 9 ms | 3320 KB | Output is correct |
18 | Correct | 4 ms | 2680 KB | Output is correct |
19 | Correct | 5 ms | 2684 KB | Output is correct |
20 | Correct | 5 ms | 2808 KB | Output is correct |
21 | Correct | 4 ms | 2552 KB | Output is correct |
22 | Correct | 5 ms | 2680 KB | Output is correct |
23 | Correct | 6 ms | 2936 KB | Output is correct |
24 | Correct | 9 ms | 3192 KB | Output is correct |
25 | Correct | 6 ms | 2936 KB | Output is correct |
26 | Correct | 6 ms | 2936 KB | Output is correct |
27 | Correct | 6 ms | 2936 KB | Output is correct |
28 | Correct | 10 ms | 3576 KB | Output is correct |
29 | Correct | 33 ms | 5876 KB | Output is correct |
30 | Correct | 10 ms | 3448 KB | Output is correct |
31 | Correct | 18 ms | 4348 KB | Output is correct |
32 | Correct | 13 ms | 3816 KB | Output is correct |
33 | Correct | 71 ms | 9064 KB | Output is correct |
34 | Correct | 71 ms | 9072 KB | Output is correct |
35 | Correct | 56 ms | 7160 KB | Output is correct |
36 | Correct | 11 ms | 3324 KB | Output is correct |
37 | Correct | 114 ms | 11148 KB | Output is correct |
38 | Correct | 95 ms | 10216 KB | Output is correct |
39 | Correct | 92 ms | 10088 KB | Output is correct |
40 | Correct | 96 ms | 10088 KB | Output is correct |
41 | Correct | 105 ms | 10132 KB | Output is correct |
42 | Correct | 13 ms | 3320 KB | Output is correct |
43 | Correct | 13 ms | 3192 KB | Output is correct |
44 | Correct | 11 ms | 3064 KB | Output is correct |
45 | Correct | 377 ms | 27684 KB | Output is correct |
46 | Correct | 361 ms | 27612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2556 KB | Output is correct |
2 | Correct | 4 ms | 2552 KB | Output is correct |
3 | Correct | 4 ms | 2524 KB | Output is correct |
4 | Correct | 4 ms | 2552 KB | Output is correct |
5 | Correct | 4 ms | 2552 KB | Output is correct |
6 | Correct | 4 ms | 2552 KB | Output is correct |
7 | Correct | 4 ms | 2552 KB | Output is correct |
8 | Correct | 4 ms | 2552 KB | Output is correct |
9 | Correct | 4 ms | 2552 KB | Output is correct |
10 | Correct | 4 ms | 2556 KB | Output is correct |
11 | Correct | 6 ms | 2808 KB | Output is correct |
12 | Correct | 5 ms | 2552 KB | Output is correct |
13 | Correct | 4 ms | 2524 KB | Output is correct |
14 | Correct | 6 ms | 2808 KB | Output is correct |
15 | Correct | 6 ms | 2808 KB | Output is correct |
16 | Correct | 5 ms | 2552 KB | Output is correct |
17 | Correct | 10 ms | 3320 KB | Output is correct |
18 | Correct | 4 ms | 2552 KB | Output is correct |
19 | Correct | 6 ms | 2552 KB | Output is correct |
20 | Correct | 5 ms | 2680 KB | Output is correct |
21 | Correct | 5 ms | 2556 KB | Output is correct |
22 | Correct | 4 ms | 2552 KB | Output is correct |
23 | Correct | 6 ms | 2808 KB | Output is correct |
24 | Correct | 9 ms | 3192 KB | Output is correct |
25 | Correct | 7 ms | 2936 KB | Output is correct |
26 | Correct | 6 ms | 2936 KB | Output is correct |
27 | Correct | 6 ms | 2936 KB | Output is correct |
28 | Correct | 12 ms | 3576 KB | Output is correct |
29 | Correct | 37 ms | 5872 KB | Output is correct |
30 | Correct | 10 ms | 3448 KB | Output is correct |
31 | Correct | 19 ms | 4344 KB | Output is correct |
32 | Correct | 12 ms | 3704 KB | Output is correct |
33 | Correct | 81 ms | 9044 KB | Output is correct |
34 | Correct | 82 ms | 9064 KB | Output is correct |
35 | Correct | 60 ms | 7152 KB | Output is correct |
36 | Correct | 12 ms | 3320 KB | Output is correct |
37 | Correct | 122 ms | 11212 KB | Output is correct |
38 | Correct | 101 ms | 10284 KB | Output is correct |
39 | Correct | 96 ms | 10060 KB | Output is correct |
40 | Correct | 108 ms | 10092 KB | Output is correct |
41 | Correct | 107 ms | 10308 KB | Output is correct |
42 | Correct | 16 ms | 3320 KB | Output is correct |
43 | Correct | 12 ms | 3192 KB | Output is correct |
44 | Correct | 11 ms | 3064 KB | Output is correct |
45 | Correct | 475 ms | 27680 KB | Output is correct |
46 | Correct | 433 ms | 27700 KB | Output is correct |
47 | Correct | 682 ms | 41716 KB | Output is correct |
48 | Correct | 13 ms | 3192 KB | Output is correct |
49 | Correct | 14 ms | 3320 KB | Output is correct |
50 | Correct | 12 ms | 3064 KB | Output is correct |
51 | Correct | 205 ms | 18532 KB | Output is correct |
52 | Correct | 244 ms | 20064 KB | Output is correct |
53 | Correct | 32 ms | 6768 KB | Output is correct |
54 | Correct | 7 ms | 3448 KB | Output is correct |
55 | Correct | 9 ms | 3832 KB | Output is correct |
56 | Correct | 21 ms | 5360 KB | Output is correct |
57 | Correct | 305 ms | 25552 KB | Output is correct |
58 | Correct | 23 ms | 6256 KB | Output is correct |
59 | Correct | 32 ms | 7792 KB | Output is correct |
60 | Correct | 50 ms | 9068 KB | Output is correct |
61 | Correct | 40 ms | 8176 KB | Output is correct |
62 | Correct | 238 ms | 25940 KB | Output is correct |
63 | Execution timed out | 1082 ms | 70828 KB | Time limit exceeded |
64 | Halted | 0 ms | 0 KB | - |