Submission #790243

#TimeUsernameProblemLanguageResultExecution timeMemory
790243Valaki2Toy Train (IOI17_train)C++14
5 / 100
5 ms856 KiB
#include "train.h" #include <bits/stdc++.h> using namespace std; int n, m; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); m = u.size(); vector<bool> to_next(n, false), to_self(n, false); for(int i = 0; i < m; i++) { if(u[i] == v[i]) { to_self[u[i]] = true; } else { to_next[u[i]] = true; } } vector<int> res(n); for(int i = n - 1; i >= 0; i--) { if(to_self[i] && !to_next[i]) { res[i] = r[i]; // loop } else if(!to_self[i] && to_next[i]) { res[i] = res[i + 1]; // step } else { if(a[i] == r[i]) { res[i] = a[i]; // loop good for owner } else { res[i] = res[i + 1]; // owner decides to step } } } return res; }
#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...