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;
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 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... |