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>
#define pb push_back
using namespace std;
const int N = 5e3 + 10;
vector<int> in[N], out[N];
bool f[N], g[N];
void add_edge(int v, int u){
out[v].pb(u);
in[u].pb(v);
if(u == v + 1) g[v] = 1;
else f[v] = 1;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int n = a.size(), m = u.size();
vector<int> res(n);
for(int i = 0; i < m; i++) add_edge(u[i], v[i]);
res[n - 1] = r[n - 1];
for(int i = n - 2; i >= 0; i--){
if(a[i]){
if((f[i] && r[i]) || (g[i] && res[i + 1])) res[i] = 1;
else res[i] = 0;
}else{
if((f[i] && !r[i]) || (g[i] && !res[i + 1])) res[i] = 0;
else res[i] = 1;
}
}
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... |