Submission #823035

#TimeUsernameProblemLanguageResultExecution timeMemory
823035Minindu206Toy Train (IOI17_train)C++14
0 / 100
2084 ms1000 KiB
#include "train.h" #include<bits/stdc++.h> using namespace std; int n, m; vector<int> aa, rr; int solve(vector<int> adj[], int pos, int cur) { int csz = adj[pos].size(); int nxt; if(csz == 1) { if(adj[pos][0] == pos) return rr[adj[pos][0]] & aa[adj[pos][0]]; else nxt = adj[pos][0]; } else { if(rr[pos]) { if(aa[pos]) return 1; else nxt = max(adj[pos][0], adj[pos][1]); } else { if(!aa[pos]) return 0; else nxt = max(adj[pos][0], adj[pos][1]); } } return solve(adj, nxt, cur + 1); } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(), m = u.size(); aa = a; rr = r; vector<int> adj[n], ans(n); for(int i=0;i<m;i++) adj[u[i]].push_back(v[i]); for(int i=0;i<n;i++) { ans[i] = solve(adj, i, 0); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...