# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
917336 | 2024-01-27T21:26:47 Z | rainboy | None (KOI17_line) | C++ | 154 ms | 21836 KB |
#include <stdio.h> #include <stdlib.h> #define N 100000 int *ei[N], eo[N]; void append(int j, int i) { int o = eo[j]++; if (o >= 2 && (o & o - 1) == 0) ei[j] = (int *) realloc(ei[j], o * 2 * sizeof *ei[j]); ei[j][o] = i; } int main() { static int aa[N]; int n, m, h, i, j, o; scanf("%d%d", &n, &m); for (j = 0; j < n; j++) ei[j] = (int *) malloc(2 * sizeof *ei[j]); for (h = 0; h < m; h++) { scanf("%d%d", &i, &j), i--, j--; append(j, i); } for (j = 0; j < n; j++) { for (o = eo[j]; o--; ) { i = ei[j][o]; if (aa[i]++ < j - eo[j]) { printf("-1\n"); return 0; } } aa[j] = j - eo[j]; } for (i = 0; i < n; i++) printf("%d ", aa[i] + 1); printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 432 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 440 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 432 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 440 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 604 KB | Output is correct |
23 | Correct | 6 ms | 936 KB | Output is correct |
24 | Correct | 14 ms | 1628 KB | Output is correct |
25 | Correct | 57 ms | 6696 KB | Output is correct |
26 | Correct | 15 ms | 1884 KB | Output is correct |
27 | Correct | 44 ms | 5276 KB | Output is correct |
28 | Correct | 46 ms | 5584 KB | Output is correct |
29 | Correct | 79 ms | 10196 KB | Output is correct |
30 | Correct | 119 ms | 14488 KB | Output is correct |
31 | Correct | 56 ms | 6696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 432 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 440 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 604 KB | Output is correct |
23 | Correct | 6 ms | 936 KB | Output is correct |
24 | Correct | 14 ms | 1628 KB | Output is correct |
25 | Correct | 57 ms | 6696 KB | Output is correct |
26 | Correct | 15 ms | 1884 KB | Output is correct |
27 | Correct | 44 ms | 5276 KB | Output is correct |
28 | Correct | 46 ms | 5584 KB | Output is correct |
29 | Correct | 79 ms | 10196 KB | Output is correct |
30 | Correct | 119 ms | 14488 KB | Output is correct |
31 | Correct | 56 ms | 6696 KB | Output is correct |
32 | Correct | 50 ms | 8152 KB | Output is correct |
33 | Correct | 64 ms | 10120 KB | Output is correct |
34 | Correct | 101 ms | 15608 KB | Output is correct |
35 | Correct | 97 ms | 14392 KB | Output is correct |
36 | Correct | 100 ms | 16008 KB | Output is correct |
37 | Correct | 126 ms | 19400 KB | Output is correct |
38 | Correct | 132 ms | 19696 KB | Output is correct |
39 | Correct | 154 ms | 21836 KB | Output is correct |
40 | Correct | 144 ms | 21588 KB | Output is correct |