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;
using ll = int;
std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
ll n = a.size();
ll m = u.size();
std::vector<int> res(a.size());
for(int i = 0; i < (int)res.size(); i++)
res[i] = i % 2;
vector<vector<ll>> con(n),rcon(n);
for(ll i = 0;i<m;i++){
con[u[i]].push_back(v[i]);
rcon[v[i]].push_back(u[i]);
}
vector<ll> ans(n,0);
for(ll i = 0;i<n;i++){
if (a[i]&&r[i]){
for(ll j : con[i]) if(j==i) ans[i] = 1;
}
}
for(ll i = n-2;i>=0;i--){
if (a[i]){
for(ll j : con[i]) if(j==i+1&&ans[i+1]) ans[i] = 1;
}else{
ans[i] = 1;
for(ll j : con[i]) {
if(j==i&&!r[i]) ans[i] = 0;
if(j==i+1&&!ans[i+1]) ans[i] = 0;
}
}
}
return ans;
}
# | 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... |