# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45445 | 2018-04-14T05:44:48 Z | RayaBurong25_1 | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | 643 ms | 262144 KB |
#include <stdio.h> #include <vector> #include <set> #include <algorithm> #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 || (a.w == b.w && a.u < b.u)); } std::set<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; std::sort(AdjList[i].begin(), AdjList[i].end()); } Min[B[0]] = 0; Q.insert({B[0], 0}); node p; int v, w, s; while (!Q.empty()) { p = *Q.begin(); Q.erase(Q.begin()); 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]) { if (Min[v] != INF) Q.erase({v, Min[v]}); Min[v] = p.w + w; Q.insert({v, Min[v]}); } } } printf("-1"); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1020 KB | Output is correct |
2 | Correct | 2 ms | 1020 KB | Output is correct |
3 | Correct | 2 ms | 1072 KB | Output is correct |
4 | Correct | 2 ms | 1088 KB | Output is correct |
5 | Correct | 2 ms | 1088 KB | Output is correct |
6 | Correct | 2 ms | 1124 KB | Output is correct |
7 | Correct | 2 ms | 1172 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1172 KB | Output is correct |
2 | Correct | 3 ms | 1172 KB | Output is correct |
3 | Correct | 3 ms | 1232 KB | Output is correct |
4 | Correct | 3 ms | 1232 KB | Output is correct |
5 | Correct | 3 ms | 1232 KB | Output is correct |
6 | Correct | 3 ms | 1232 KB | Output is correct |
7 | Correct | 2 ms | 1232 KB | Output is correct |
8 | Correct | 3 ms | 1232 KB | Output is correct |
9 | Correct | 2 ms | 1232 KB | Output is correct |
10 | Correct | 3 ms | 1236 KB | Output is correct |
11 | Correct | 6 ms | 1360 KB | Output is correct |
12 | Correct | 17 ms | 3396 KB | Output is correct |
13 | Correct | 17 ms | 3424 KB | Output is correct |
14 | Correct | 5 ms | 3424 KB | Output is correct |
15 | Correct | 4 ms | 3424 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3424 KB | Output is correct |
2 | Correct | 3 ms | 3424 KB | Output is correct |
3 | Correct | 2 ms | 3424 KB | Output is correct |
4 | Correct | 2 ms | 3424 KB | Output is correct |
5 | Correct | 2 ms | 3424 KB | Output is correct |
6 | Correct | 3 ms | 3424 KB | Output is correct |
7 | Correct | 3 ms | 3424 KB | Output is correct |
8 | Correct | 2 ms | 3424 KB | Output is correct |
9 | Correct | 3 ms | 3424 KB | Output is correct |
10 | Correct | 3 ms | 3424 KB | Output is correct |
11 | Correct | 6 ms | 3424 KB | Output is correct |
12 | Correct | 17 ms | 3484 KB | Output is correct |
13 | Correct | 22 ms | 3488 KB | Output is correct |
14 | Correct | 4 ms | 3488 KB | Output is correct |
15 | Correct | 4 ms | 3488 KB | Output is correct |
16 | Correct | 5 ms | 3488 KB | Output is correct |
17 | Correct | 12 ms | 3488 KB | Output is correct |
18 | Correct | 14 ms | 3488 KB | Output is correct |
19 | Correct | 12 ms | 3488 KB | Output is correct |
20 | Correct | 135 ms | 33404 KB | Output is correct |
21 | Correct | 5 ms | 33404 KB | Output is correct |
22 | Correct | 10 ms | 33404 KB | Output is correct |
23 | Correct | 12 ms | 33404 KB | Output is correct |
24 | Correct | 29 ms | 33404 KB | Output is correct |
25 | Correct | 26 ms | 33404 KB | Output is correct |
26 | Correct | 310 ms | 34368 KB | Output is correct |
27 | Correct | 281 ms | 34368 KB | Output is correct |
28 | Correct | 30 ms | 34368 KB | Output is correct |
29 | Correct | 18 ms | 34368 KB | Output is correct |
30 | Correct | 7 ms | 34368 KB | Output is correct |
31 | Correct | 12 ms | 34368 KB | Output is correct |
32 | Correct | 14 ms | 34368 KB | Output is correct |
33 | Correct | 43 ms | 34368 KB | Output is correct |
34 | Correct | 39 ms | 34368 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 34368 KB | Output is correct |
2 | Correct | 3 ms | 34368 KB | Output is correct |
3 | Correct | 2 ms | 34368 KB | Output is correct |
4 | Correct | 3 ms | 34368 KB | Output is correct |
5 | Correct | 2 ms | 34368 KB | Output is correct |
6 | Correct | 3 ms | 34368 KB | Output is correct |
7 | Correct | 2 ms | 34368 KB | Output is correct |
8 | Correct | 2 ms | 34368 KB | Output is correct |
9 | Correct | 2 ms | 34368 KB | Output is correct |
10 | Correct | 3 ms | 34368 KB | Output is correct |
11 | Correct | 5 ms | 34368 KB | Output is correct |
12 | Correct | 19 ms | 34368 KB | Output is correct |
13 | Correct | 22 ms | 34368 KB | Output is correct |
14 | Correct | 6 ms | 34368 KB | Output is correct |
15 | Correct | 6 ms | 34368 KB | Output is correct |
16 | Correct | 5 ms | 34368 KB | Output is correct |
17 | Correct | 12 ms | 34368 KB | Output is correct |
18 | Correct | 12 ms | 34368 KB | Output is correct |
19 | Correct | 9 ms | 34368 KB | Output is correct |
20 | Correct | 159 ms | 34368 KB | Output is correct |
21 | Correct | 7 ms | 34368 KB | Output is correct |
22 | Correct | 10 ms | 34368 KB | Output is correct |
23 | Correct | 12 ms | 34368 KB | Output is correct |
24 | Correct | 24 ms | 34368 KB | Output is correct |
25 | Correct | 25 ms | 34368 KB | Output is correct |
26 | Correct | 327 ms | 34368 KB | Output is correct |
27 | Correct | 290 ms | 34368 KB | Output is correct |
28 | Correct | 26 ms | 34368 KB | Output is correct |
29 | Correct | 25 ms | 34368 KB | Output is correct |
30 | Correct | 6 ms | 34368 KB | Output is correct |
31 | Correct | 14 ms | 34368 KB | Output is correct |
32 | Correct | 10 ms | 34368 KB | Output is correct |
33 | Correct | 38 ms | 34368 KB | Output is correct |
34 | Correct | 37 ms | 34368 KB | Output is correct |
35 | Correct | 241 ms | 34368 KB | Output is correct |
36 | Correct | 33 ms | 34368 KB | Output is correct |
37 | Correct | 236 ms | 34368 KB | Output is correct |
38 | Correct | 385 ms | 34368 KB | Output is correct |
39 | Correct | 362 ms | 34368 KB | Output is correct |
40 | Correct | 372 ms | 34368 KB | Output is correct |
41 | Correct | 398 ms | 34368 KB | Output is correct |
42 | Runtime error | 643 ms | 262144 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
43 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 262144 KB | Output is correct |
2 | Correct | 2 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 | 2 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 | 5 ms | 262144 KB | Output is correct |
12 | Correct | 19 ms | 262144 KB | Output is correct |
13 | Correct | 19 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 | 12 ms | 262144 KB | Output is correct |
18 | Correct | 12 ms | 262144 KB | Output is correct |
19 | Correct | 13 ms | 262144 KB | Output is correct |
20 | Correct | 165 ms | 262144 KB | Output is correct |
21 | Correct | 5 ms | 262144 KB | Output is correct |
22 | Correct | 10 ms | 262144 KB | Output is correct |
23 | Correct | 12 ms | 262144 KB | Output is correct |
24 | Correct | 24 ms | 262144 KB | Output is correct |
25 | Correct | 32 ms | 262144 KB | Output is correct |
26 | Correct | 306 ms | 262144 KB | Output is correct |
27 | Correct | 332 ms | 262144 KB | Output is correct |
28 | Correct | 28 ms | 262144 KB | Output is correct |
29 | Correct | 26 ms | 262144 KB | Output is correct |
30 | Correct | 10 ms | 262144 KB | Output is correct |
31 | Correct | 14 ms | 262144 KB | Output is correct |
32 | Correct | 11 ms | 262144 KB | Output is correct |
33 | Correct | 46 ms | 262144 KB | Output is correct |
34 | Correct | 45 ms | 262144 KB | Output is correct |
35 | Correct | 236 ms | 262144 KB | Output is correct |
36 | Correct | 49 ms | 262144 KB | Output is correct |
37 | Correct | 268 ms | 262144 KB | Output is correct |
38 | Correct | 500 ms | 262144 KB | Output is correct |
39 | Correct | 433 ms | 262144 KB | Output is correct |
40 | Correct | 407 ms | 262144 KB | Output is correct |
41 | Correct | 372 ms | 262144 KB | Output is correct |
42 | Runtime error | 547 ms | 262144 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
43 | Halted | 0 ms | 0 KB | - |