# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
295773 | 2020-09-09T22:59:06 Z | DanerZein | Toy Train (IOI17_train) | C++14 | 10 ms | 1536 KB |
#include "train.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; vector<vi> G; bitset<5010> ab,cs; int vis[5010]; vi res; bool dfs(int u){ //cout<<u<<endl; vis[u]=2; if(ab[u]==1){ int x=-1; for(auto &v:G[u]){ if(v==u and cs[v]==1){ res[u]=1; return 1; } else{ if(v!=u) x=v; } } if(x!=-1 and vis[x]==-1) return res[u]=dfs(x); return 0; } else{ int x=-1; for(auto &v:G[u]){ if(v==u and cs[v]==0){ res[u]=0; return 0; } else{ if(v!=u) x=v; } } if(x!=-1 and vis[x]==-1) return res[u]=dfs(x); return 1; } } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { for(int i=0;i<a.size();i++){ ab[i]=a[i]; cs[i]=r[i]; } int n=a.size(); G.resize(n+1); res.resize(n); for(int i=0;i<u.size();i++){ int x=u[i],y=v[i]; G[x].push_back(y); G[y].push_back(x); } memset(vis,-1,sizeof vis); for(int i=0;i<a.size();i++){ if(vis[i]==-1){ dfs(i); } } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 896 KB | 3rd lines differ - on the 7th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 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 | 8 ms | 1536 KB | Output is correct |
2 | Correct | 8 ms | 1536 KB | Output is correct |
3 | Correct | 9 ms | 1408 KB | Output is correct |
4 | Incorrect | 10 ms | 1536 KB | 3rd lines differ - on the 1st token, expected: '1', found: '0' |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 1280 KB | 3rd lines differ - on the 97th token, expected: '1', found: '0' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 1408 KB | 3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 896 KB | 3rd lines differ - on the 7th token, expected: '0', found: '1' |
2 | Halted | 0 ms | 0 KB | - |