# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45448 | 2018-04-14T06:23:56 Z | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 555 ms | 121124 KB |
#include <stdio.h> #include <vector> #include <queue> #include <algorithm> #define INF 1000000007 int B[30005], P[30005]; int abs(int a) { return (a < 0)?-a:a; } long long Vis[30005][505]; typedef struct node node; struct node { int u, j, t; }; std::vector<int> J[30005]; std::queue<node> Q; int main() { int N, M; scanf("%d %d", &N, &M); int i; node p; for (i = 0; i < M; i++) { scanf("%d %d", &B[i], &P[i]); if (i == 0) p = {B[i], P[i], 0}; else J[B[i]].push_back(P[i]); } Vis[B[0]][P[i]/60] |= (1LL << (P[i]%60)); Q.push(p); int w; while (!Q.empty()) { p = Q.front(); Q.pop(); // printf("pop %d %d %d\n", p.u, p.j, p.t); if (p.u == B[1]) { printf("%d", p.t); return 0; } if (p.u + p.j < N && (Vis[p.u + p.j][p.j/60]&(1LL << (p.j%60))) == 0) { Vis[p.u + p.j][p.j/60] |= (1LL << (p.j%60)); Q.push({p.u + p.j, p.j, p.t + 1}); } if (p.u - p.j >= 0 && (Vis[p.u - p.j][p.j/60]&(1LL << (p.j%60))) == 0) { Vis[p.u - p.j][p.j/60] |= (1LL << (p.j%60)); Q.push({p.u - p.j, p.j, p.t + 1}); } for (i = 0; i < J[p.u].size(); i++) { w = J[p.u][i]; if (p.u + w < N && (Vis[p.u + w][w/60]&(1LL << (w%60))) == 0) { Vis[p.u + w][w/60] |= (1LL << (w%60)); Q.push({p.u + w, w, p.t + 1}); } if (p.u - w >= 0 && (Vis[p.u - w][w/60]&(1LL << (w%60))) == 0) { Vis[p.u - w][w/60] |= (1LL << (w%60)); Q.push({p.u - w, w, p.t + 1}); } } } printf("-1"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1016 KB | Output is correct |
2 | Correct | 2 ms | 1016 KB | Output is correct |
3 | Correct | 2 ms | 1048 KB | Output is correct |
4 | Correct | 3 ms | 1048 KB | Output is correct |
5 | Correct | 2 ms | 1236 KB | Output is correct |
6 | Correct | 2 ms | 1236 KB | Output is correct |
7 | Correct | 2 ms | 1236 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 2 ms | 1236 KB | Output is correct |
5 | Correct | 2 ms | 1236 KB | Output is correct |
6 | Correct | 3 ms | 1236 KB | Output is correct |
7 | Correct | 3 ms | 1236 KB | Output is correct |
8 | Correct | 2 ms | 1236 KB | Output is correct |
9 | Correct | 2 ms | 1328 KB | Output is correct |
10 | Correct | 3 ms | 1456 KB | Output is correct |
11 | Correct | 3 ms | 1456 KB | Output is correct |
12 | Correct | 3 ms | 1584 KB | Output is correct |
13 | Correct | 3 ms | 1584 KB | Output is correct |
14 | Correct | 4 ms | 1584 KB | Output is correct |
15 | Correct | 3 ms | 1712 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1712 KB | Output is correct |
2 | Correct | 2 ms | 1712 KB | Output is correct |
3 | Correct | 2 ms | 1712 KB | Output is correct |
4 | Correct | 2 ms | 1712 KB | Output is correct |
5 | Correct | 2 ms | 1712 KB | Output is correct |
6 | Correct | 2 ms | 1712 KB | Output is correct |
7 | Correct | 2 ms | 1712 KB | Output is correct |
8 | Correct | 2 ms | 1712 KB | Output is correct |
9 | Correct | 2 ms | 1712 KB | Output is correct |
10 | Correct | 3 ms | 1712 KB | Output is correct |
11 | Correct | 3 ms | 1712 KB | Output is correct |
12 | Correct | 3 ms | 1712 KB | Output is correct |
13 | Correct | 3 ms | 1712 KB | Output is correct |
14 | Correct | 4 ms | 1788 KB | Output is correct |
15 | Correct | 4 ms | 1788 KB | Output is correct |
16 | Correct | 2 ms | 1788 KB | Output is correct |
17 | Correct | 6 ms | 4220 KB | Output is correct |
18 | Correct | 3 ms | 4220 KB | Output is correct |
19 | Correct | 3 ms | 4220 KB | Output is correct |
20 | Correct | 11 ms | 9208 KB | Output is correct |
21 | Correct | 3 ms | 9208 KB | Output is correct |
22 | Correct | 2 ms | 9208 KB | Output is correct |
23 | Correct | 9 ms | 9208 KB | Output is correct |
24 | Correct | 10 ms | 9208 KB | Output is correct |
25 | Correct | 4 ms | 9208 KB | Output is correct |
26 | Correct | 9 ms | 9208 KB | Output is correct |
27 | Correct | 10 ms | 9208 KB | Output is correct |
28 | Correct | 12 ms | 9212 KB | Output is correct |
29 | Correct | 11 ms | 9212 KB | Output is correct |
30 | Correct | 11 ms | 9292 KB | Output is correct |
31 | Correct | 13 ms | 9292 KB | Output is correct |
32 | Correct | 11 ms | 9292 KB | Output is correct |
33 | Correct | 15 ms | 9292 KB | Output is correct |
34 | Correct | 14 ms | 9292 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 9292 KB | Output is correct |
2 | Correct | 2 ms | 9292 KB | Output is correct |
3 | Correct | 2 ms | 9292 KB | Output is correct |
4 | Correct | 2 ms | 9292 KB | Output is correct |
5 | Correct | 2 ms | 9292 KB | Output is correct |
6 | Correct | 3 ms | 9292 KB | Output is correct |
7 | Correct | 3 ms | 9292 KB | Output is correct |
8 | Correct | 2 ms | 9292 KB | Output is correct |
9 | Correct | 3 ms | 9292 KB | Output is correct |
10 | Correct | 3 ms | 9292 KB | Output is correct |
11 | Correct | 4 ms | 9292 KB | Output is correct |
12 | Correct | 3 ms | 9292 KB | Output is correct |
13 | Correct | 3 ms | 9292 KB | Output is correct |
14 | Correct | 4 ms | 9292 KB | Output is correct |
15 | Correct | 3 ms | 9292 KB | Output is correct |
16 | Correct | 2 ms | 9292 KB | Output is correct |
17 | Correct | 6 ms | 9292 KB | Output is correct |
18 | Correct | 3 ms | 9292 KB | Output is correct |
19 | Correct | 2 ms | 9292 KB | Output is correct |
20 | Correct | 11 ms | 9296 KB | Output is correct |
21 | Correct | 2 ms | 9296 KB | Output is correct |
22 | Correct | 3 ms | 9296 KB | Output is correct |
23 | Correct | 9 ms | 9296 KB | Output is correct |
24 | Correct | 14 ms | 9296 KB | Output is correct |
25 | Correct | 6 ms | 9296 KB | Output is correct |
26 | Correct | 10 ms | 9296 KB | Output is correct |
27 | Correct | 10 ms | 9296 KB | Output is correct |
28 | Correct | 12 ms | 9296 KB | Output is correct |
29 | Correct | 12 ms | 9296 KB | Output is correct |
30 | Correct | 11 ms | 9296 KB | Output is correct |
31 | Correct | 12 ms | 9296 KB | Output is correct |
32 | Correct | 12 ms | 9296 KB | Output is correct |
33 | Correct | 15 ms | 9304 KB | Output is correct |
34 | Correct | 13 ms | 9304 KB | Output is correct |
35 | Correct | 18 ms | 9304 KB | Output is correct |
36 | Correct | 6 ms | 9304 KB | Output is correct |
37 | Correct | 17 ms | 9468 KB | Output is correct |
38 | Correct | 20 ms | 9980 KB | Output is correct |
39 | Correct | 12 ms | 9980 KB | Output is correct |
40 | Correct | 14 ms | 9980 KB | Output is correct |
41 | Correct | 19 ms | 9980 KB | Output is correct |
42 | Correct | 16 ms | 9980 KB | Output is correct |
43 | Correct | 16 ms | 9980 KB | Output is correct |
44 | Correct | 17 ms | 9980 KB | Output is correct |
45 | Correct | 68 ms | 10284 KB | Output is correct |
46 | Correct | 59 ms | 10284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10284 KB | Output is correct |
2 | Correct | 2 ms | 10284 KB | Output is correct |
3 | Correct | 2 ms | 10284 KB | Output is correct |
4 | Correct | 3 ms | 10284 KB | Output is correct |
5 | Correct | 3 ms | 10284 KB | Output is correct |
6 | Correct | 2 ms | 10284 KB | Output is correct |
7 | Correct | 3 ms | 10284 KB | Output is correct |
8 | Correct | 3 ms | 10284 KB | Output is correct |
9 | Correct | 2 ms | 10284 KB | Output is correct |
10 | Correct | 4 ms | 10284 KB | Output is correct |
11 | Correct | 4 ms | 10284 KB | Output is correct |
12 | Correct | 4 ms | 10284 KB | Output is correct |
13 | Correct | 4 ms | 10284 KB | Output is correct |
14 | Correct | 4 ms | 10284 KB | Output is correct |
15 | Correct | 3 ms | 10284 KB | Output is correct |
16 | Correct | 3 ms | 10284 KB | Output is correct |
17 | Correct | 7 ms | 10284 KB | Output is correct |
18 | Correct | 3 ms | 10284 KB | Output is correct |
19 | Correct | 3 ms | 10284 KB | Output is correct |
20 | Correct | 12 ms | 10284 KB | Output is correct |
21 | Correct | 3 ms | 10284 KB | Output is correct |
22 | Correct | 3 ms | 10284 KB | Output is correct |
23 | Correct | 11 ms | 10284 KB | Output is correct |
24 | Correct | 14 ms | 10284 KB | Output is correct |
25 | Correct | 5 ms | 10284 KB | Output is correct |
26 | Correct | 11 ms | 10284 KB | Output is correct |
27 | Correct | 12 ms | 10284 KB | Output is correct |
28 | Correct | 13 ms | 10284 KB | Output is correct |
29 | Correct | 16 ms | 10284 KB | Output is correct |
30 | Correct | 14 ms | 10284 KB | Output is correct |
31 | Correct | 15 ms | 10284 KB | Output is correct |
32 | Correct | 11 ms | 10284 KB | Output is correct |
33 | Correct | 18 ms | 10284 KB | Output is correct |
34 | Correct | 14 ms | 10284 KB | Output is correct |
35 | Correct | 18 ms | 10284 KB | Output is correct |
36 | Correct | 7 ms | 10284 KB | Output is correct |
37 | Correct | 23 ms | 10284 KB | Output is correct |
38 | Correct | 29 ms | 10284 KB | Output is correct |
39 | Correct | 12 ms | 10284 KB | Output is correct |
40 | Correct | 14 ms | 10284 KB | Output is correct |
41 | Correct | 19 ms | 10284 KB | Output is correct |
42 | Correct | 16 ms | 10284 KB | Output is correct |
43 | Correct | 24 ms | 10284 KB | Output is correct |
44 | Correct | 25 ms | 10284 KB | Output is correct |
45 | Correct | 81 ms | 10284 KB | Output is correct |
46 | Correct | 70 ms | 10284 KB | Output is correct |
47 | Correct | 39 ms | 27260 KB | Output is correct |
48 | Correct | 18 ms | 27260 KB | Output is correct |
49 | Correct | 18 ms | 27260 KB | Output is correct |
50 | Correct | 8 ms | 27260 KB | Output is correct |
51 | Correct | 113 ms | 89492 KB | Output is correct |
52 | Correct | 128 ms | 95516 KB | Output is correct |
53 | Correct | 31 ms | 95516 KB | Output is correct |
54 | Correct | 64 ms | 95516 KB | Output is correct |
55 | Correct | 86 ms | 95516 KB | Output is correct |
56 | Correct | 148 ms | 121124 KB | Output is correct |
57 | Correct | 5 ms | 121124 KB | Output is correct |
58 | Correct | 149 ms | 121124 KB | Output is correct |
59 | Correct | 124 ms | 121124 KB | Output is correct |
60 | Correct | 132 ms | 121124 KB | Output is correct |
61 | Correct | 129 ms | 121124 KB | Output is correct |
62 | Correct | 191 ms | 121124 KB | Output is correct |
63 | Correct | 293 ms | 121124 KB | Output is correct |
64 | Correct | 301 ms | 121124 KB | Output is correct |
65 | Correct | 354 ms | 121124 KB | Output is correct |
66 | Correct | 555 ms | 121124 KB | Output is correct |
67 | Correct | 409 ms | 121124 KB | Output is correct |