This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size();
int m = u.size();
vector<bool> presentself(n);
vector<bool> presentnext(n);
for(int i=0;i<m;i++) {
if(v[i]==u[i])presentself[u[i]]=true;
else presentnext[u[i]]=true;
}
vector<int> wins(n,-1);
for(int i=0;i<n;i++){
bool want_cycle = a[i]==r[i];
bool get_cycle = !presentnext[i] or (want_cycle and presentself[i]);
if(get_cycle) {
if(want_cycle)wins[i]=a[i];
else wins[i]=a[i]^1;
}
}
for(int i=n-2;i>=0;i--)if(wins[i]==-1)wins[i]=wins[i+1];
return wins;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |