# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
593458 | 2022-07-11T08:22:34 Z | keta_tsimakuridze | Toy Train (IOI17_train) | C++14 | 7 ms | 1364 KB |
#include "train.h" #include<bits/stdc++.h> using namespace std; const int N = 5005; int f[N], out[N], vis[N], a[N]; vector<int> in[N]; void go(vector<int> cur, int t) { while(cur.size()) { int u = cur.back(); cur.pop_back(); for(int i = 0; i < in[u].size(); i++) { int v = in[u][i]; if(vis[v]) continue; out[v]--; if(a[v] == t || !out[v]) vis[v] = 1, cur.push_back(v); } } } std::vector<int> who_wins(std::vector<int> A, std::vector<int> r, std::vector<int> u, std::vector<int> v) { int n = A.size(), m = v.size(); vector<int> w(n); for(int i = 0; i < n; i++) w[i] = 1, a[i] = A[i]; for(int i = 0; i < m; i++) in[v[i]].push_back(u[i]); while(true) { for(int i = 0; i < n; i++) vis[i] = 0, out[i] = 0; for(int i = 0; i < m; i++) ++out[u[i]]; vector<int> cur; for(int i = 0; i < r.size(); i++) { if(!f[r[i]]) { cur.push_back(r[i]); vis[r[i]] = 1; } } go(cur, 1); int F = 0; for(int i = 0; i < n; i++) { if(!f[i] && !vis[i]) { f[i] = 1; F = 1; } } if(!F) break; cur.clear(); for(int i = 0; i < n; i++) vis[i] = 0, out[i] = 0; for(int i = 0; i < m; i++) ++out[u[i]]; for(int i = 0; i < n; i++) { if(f[i]) cur.push_back(i), vis[i] = 1; } go(cur, 0); for(int i = 0; i < n; i++) { f[i] = vis[i]; w[i] = 1 - f[i]; } } return w; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 980 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 340 KB | 3rd lines differ - on the 2nd token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1328 KB | Output is correct |
2 | Correct | 6 ms | 1364 KB | Output is correct |
3 | Incorrect | 6 ms | 1328 KB | 3rd lines differ - on the 2nd token, expected: '0', found: '1' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1200 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 1364 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 980 KB | 3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |