# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45447 | 2018-04-14T06:22:58 Z | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 4 ms | 1664 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] |= (1 << (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]&(1 << (p.j%60))) == 0) { Vis[p.u + p.j][p.j/60] |= (1 << (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]&(1 << (p.j%60))) == 0) { Vis[p.u - p.j][p.j/60] |= (1 << (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]&(1 << (w%60))) == 0) { Vis[p.u + w][w/60] |= (1 << (w%60)); Q.push({p.u + w, w, p.t + 1}); } if (p.u - w >= 0 && (Vis[p.u - w][w/60]&(1 << (w%60))) == 0) { Vis[p.u - w][w/60] |= (1 << (w%60)); Q.push({p.u - w, w, p.t + 1}); } } } printf("-1"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 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 | 2 ms | 1100 KB | Output is correct |
5 | Correct | 3 ms | 1100 KB | Output is correct |
6 | Correct | 2 ms | 1100 KB | Output is correct |
7 | Correct | 3 ms | 1152 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1152 KB | Output is correct |
2 | Correct | 2 ms | 1200 KB | Output is correct |
3 | Correct | 2 ms | 1212 KB | Output is correct |
4 | Correct | 2 ms | 1236 KB | Output is correct |
5 | Correct | 2 ms | 1236 KB | Output is correct |
6 | Correct | 2 ms | 1236 KB | Output is correct |
7 | Correct | 3 ms | 1236 KB | Output is correct |
8 | Correct | 3 ms | 1364 KB | Output is correct |
9 | Correct | 3 ms | 1380 KB | Output is correct |
10 | Correct | 4 ms | 1508 KB | Output is correct |
11 | Correct | 4 ms | 1508 KB | Output is correct |
12 | Correct | 4 ms | 1528 KB | Output is correct |
13 | Correct | 3 ms | 1636 KB | Output is correct |
14 | Incorrect | 4 ms | 1644 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1644 KB | Output is correct |
2 | Correct | 2 ms | 1644 KB | Output is correct |
3 | Correct | 2 ms | 1644 KB | Output is correct |
4 | Correct | 3 ms | 1644 KB | Output is correct |
5 | Correct | 2 ms | 1644 KB | Output is correct |
6 | Correct | 2 ms | 1644 KB | Output is correct |
7 | Correct | 2 ms | 1644 KB | Output is correct |
8 | Correct | 2 ms | 1644 KB | Output is correct |
9 | Correct | 2 ms | 1644 KB | Output is correct |
10 | Correct | 3 ms | 1644 KB | Output is correct |
11 | Correct | 3 ms | 1644 KB | Output is correct |
12 | Correct | 3 ms | 1660 KB | Output is correct |
13 | Correct | 3 ms | 1660 KB | Output is correct |
14 | Incorrect | 4 ms | 1660 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1660 KB | Output is correct |
2 | Correct | 3 ms | 1660 KB | Output is correct |
3 | Correct | 2 ms | 1660 KB | Output is correct |
4 | Correct | 3 ms | 1660 KB | Output is correct |
5 | Correct | 2 ms | 1660 KB | Output is correct |
6 | Correct | 3 ms | 1660 KB | Output is correct |
7 | Correct | 2 ms | 1660 KB | Output is correct |
8 | Correct | 2 ms | 1660 KB | Output is correct |
9 | Correct | 3 ms | 1660 KB | Output is correct |
10 | Correct | 3 ms | 1660 KB | Output is correct |
11 | Correct | 4 ms | 1660 KB | Output is correct |
12 | Correct | 4 ms | 1660 KB | Output is correct |
13 | Correct | 4 ms | 1660 KB | Output is correct |
14 | Incorrect | 4 ms | 1664 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1664 KB | Output is correct |
2 | Correct | 3 ms | 1664 KB | Output is correct |
3 | Correct | 2 ms | 1664 KB | Output is correct |
4 | Correct | 2 ms | 1664 KB | Output is correct |
5 | Correct | 2 ms | 1664 KB | Output is correct |
6 | Correct | 3 ms | 1664 KB | Output is correct |
7 | Correct | 2 ms | 1664 KB | Output is correct |
8 | Correct | 2 ms | 1664 KB | Output is correct |
9 | Correct | 3 ms | 1664 KB | Output is correct |
10 | Correct | 3 ms | 1664 KB | Output is correct |
11 | Correct | 3 ms | 1664 KB | Output is correct |
12 | Correct | 3 ms | 1664 KB | Output is correct |
13 | Correct | 3 ms | 1664 KB | Output is correct |
14 | Incorrect | 4 ms | 1664 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |