# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428625 | 2021-06-15T13:16:18 Z | vanic | Toy Train (IOI17_train) | C++14 | 2000 ms | 1316 KB |
#include "train.h" #include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; const int maxn=5005; int n, m; vector < int > ms[maxn]; int charge[maxn]; bool tko[maxn]; bool bio[maxn]; vector < int > sol; vector < int > put; int dfs(int x){ if(bio[x]){ bool p=0; for(int i=0; i<put.size(); i++){ if(put[i]==x){ p=1; } if(p){ if(charge[put[i]]){ return 1; } } } return 0; } put.push_back(x); bio[x]=1; for(int i=0; i<ms[x].size(); i++){ if(dfs(ms[x][i])==tko[x]){ bio[x]=0; put.pop_back(); return tko[x]; } } bio[x]=0; put.pop_back(); return !tko[x]; } vector < int > who_wins(vector < int > a, vector < int > r, vector < int > u, vector < int > v) { n=a.size(); m=u.size(); for(int i=0; i<n; i++){ tko[i]=a[i]; charge[i]=r[i]; } for(int i=0; i<m; i++){ ms[u[i]].push_back(v[i]); } sol.resize(n, 0); for(int i=0; i<n; i++){ sol[i]=dfs(i); } return sol; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 908 KB | Output is correct |
2 | Correct | 6 ms | 840 KB | Output is correct |
3 | Correct | 6 ms | 844 KB | Output is correct |
4 | Correct | 7 ms | 844 KB | Output is correct |
5 | Correct | 6 ms | 812 KB | Output is correct |
6 | Correct | 6 ms | 876 KB | Output is correct |
7 | Correct | 7 ms | 844 KB | Output is correct |
8 | Correct | 5 ms | 844 KB | Output is correct |
9 | Correct | 5 ms | 844 KB | Output is correct |
10 | Correct | 4 ms | 836 KB | Output is correct |
11 | Correct | 4 ms | 856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 352 KB | Output is correct |
3 | Correct | 1 ms | 412 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 416 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 | 344 KB | Output is correct |
9 | Correct | 1 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 | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 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 | 1 ms | 416 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2045 ms | 1228 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2037 ms | 1228 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2053 ms | 1316 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 908 KB | Output is correct |
2 | Correct | 6 ms | 840 KB | Output is correct |
3 | Correct | 6 ms | 844 KB | Output is correct |
4 | Correct | 7 ms | 844 KB | Output is correct |
5 | Correct | 6 ms | 812 KB | Output is correct |
6 | Correct | 6 ms | 876 KB | Output is correct |
7 | Correct | 7 ms | 844 KB | Output is correct |
8 | Correct | 5 ms | 844 KB | Output is correct |
9 | Correct | 5 ms | 844 KB | Output is correct |
10 | Correct | 4 ms | 836 KB | Output is correct |
11 | Correct | 4 ms | 856 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 352 KB | Output is correct |
14 | Correct | 1 ms | 412 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 416 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 | 344 KB | Output is correct |
20 | Correct | 1 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 | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 1 ms | 332 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 1 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 1 ms | 416 KB | Output is correct |
32 | Execution timed out | 2045 ms | 1228 KB | Time limit exceeded |
33 | Halted | 0 ms | 0 KB | - |