# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430559 | 2021-06-16T15:54:28 Z | rainboy | Toy Train (IOI17_train) | C++ | 2000 ms | 56500 KB |
#include "train.h" #include <stdlib.h> using namespace std; const int N = 5000; typedef vector<int> vi; int *ej[N], eo[N]; short dd[N][N + 1], out[N], n; char rr[N]; void dfs(int i, int t) { int o; if (--dd[i][t] != 0) return; dd[i][t] = -1; for (o = eo[i]; o--; ) { int j = ej[i][o], t_; if (t != n) dfs(j, t + 1); else if (rr[i]) for (t_ = 1; t_ <= n; t_++) dfs(j, t_); } } vi who_wins(vi aa, vi rr_, vi uu, vi vv) { int m = uu.size(), h, i, j, t; vi ans(n = aa.size()); for (i = 0; i < n; i++) rr[i] = rr_[i]; for (h = 0; h < m; h++) out[uu[h]]++, eo[vv[h]]++; for (i = 0; i < n; i++) ej[i] = (int *) malloc(eo[i] * sizeof *ej[i]), eo[i] = 0; for (h = 0; h < m; h++) ej[vv[h]][eo[vv[h]]++] = uu[h]; for (i = 0; i < n; i++) { dd[i][0] = !rr[i] ? 1 : 0; for (t = 1; t <= n; t++) dd[i][t] = t == n || !rr[i] ? (aa[i] ? out[i] : 1) : 0; } for (i = 0; i < n; i++) dfs(i, 0); for (i = 0; i < n; i++) ans[i] = dd[i][n] >= 0; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 209 ms | 50116 KB | Output is correct |
2 | Correct | 219 ms | 50016 KB | Output is correct |
3 | Correct | 210 ms | 50016 KB | Output is correct |
4 | Correct | 226 ms | 50120 KB | Output is correct |
5 | Correct | 217 ms | 49992 KB | Output is correct |
6 | Correct | 208 ms | 49952 KB | Output is correct |
7 | Correct | 307 ms | 50124 KB | Output is correct |
8 | Correct | 98 ms | 49956 KB | Output is correct |
9 | Correct | 208 ms | 49988 KB | Output is correct |
10 | Correct | 208 ms | 49988 KB | Output is correct |
11 | Correct | 197 ms | 50116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 332 KB | Output is correct |
6 | Correct | 1 ms | 332 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 1 ms | 332 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1591 ms | 50632 KB | Output is correct |
2 | Correct | 1230 ms | 50656 KB | Output is correct |
3 | Correct | 1032 ms | 50604 KB | Output is correct |
4 | Correct | 313 ms | 50244 KB | Output is correct |
5 | Correct | 881 ms | 50372 KB | Output is correct |
6 | Execution timed out | 2087 ms | 50136 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 50116 KB | Output is correct |
2 | Correct | 402 ms | 50200 KB | Output is correct |
3 | Correct | 1278 ms | 50272 KB | Output is correct |
4 | Correct | 887 ms | 56500 KB | Output is correct |
5 | Correct | 720 ms | 50652 KB | Output is correct |
6 | Correct | 513 ms | 50732 KB | Output is correct |
7 | Correct | 397 ms | 51404 KB | Output is correct |
8 | Correct | 1196 ms | 51004 KB | Output is correct |
9 | Correct | 161 ms | 50884 KB | Output is correct |
10 | Correct | 63 ms | 49792 KB | Output is correct |
11 | Correct | 59 ms | 49748 KB | Output is correct |
12 | Correct | 64 ms | 49732 KB | Output is correct |
13 | Correct | 1234 ms | 50244 KB | Output is correct |
14 | Correct | 579 ms | 50116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1337 ms | 50236 KB | Output is correct |
2 | Correct | 76 ms | 49796 KB | Output is correct |
3 | Correct | 639 ms | 50232 KB | Output is correct |
4 | Correct | 82 ms | 49764 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1163 ms | 50012 KB | Output is correct |
7 | Correct | 41 ms | 3148 KB | Output is correct |
8 | Correct | 117 ms | 3276 KB | Output is correct |
9 | Correct | 51 ms | 3148 KB | Output is correct |
10 | Correct | 3 ms | 716 KB | Output is correct |
11 | Correct | 32 ms | 4992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 209 ms | 50116 KB | Output is correct |
2 | Correct | 219 ms | 50016 KB | Output is correct |
3 | Correct | 210 ms | 50016 KB | Output is correct |
4 | Correct | 226 ms | 50120 KB | Output is correct |
5 | Correct | 217 ms | 49992 KB | Output is correct |
6 | Correct | 208 ms | 49952 KB | Output is correct |
7 | Correct | 307 ms | 50124 KB | Output is correct |
8 | Correct | 98 ms | 49956 KB | Output is correct |
9 | Correct | 208 ms | 49988 KB | Output is correct |
10 | Correct | 208 ms | 49988 KB | Output is correct |
11 | Correct | 197 ms | 50116 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 1 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 0 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 0 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1591 ms | 50632 KB | Output is correct |
33 | Correct | 1230 ms | 50656 KB | Output is correct |
34 | Correct | 1032 ms | 50604 KB | Output is correct |
35 | Correct | 313 ms | 50244 KB | Output is correct |
36 | Correct | 881 ms | 50372 KB | Output is correct |
37 | Execution timed out | 2087 ms | 50136 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |