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 <bits/stdc++.h>
#include "train.h"
using namespace std;
typedef long long ll;
vector<vector<ll>> adj;
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
ll n = a.size(), m = u.size();
vector<int> res(n);
adj = vector<vector<ll>>(n);
for (int i = 0; i < m; i++) {
adj[u[i]].push_back(v[i]);
}
for (int i = n-1; i >= 0; i--) {
bool win = false;
if (a[i]) {
for (auto &e : adj[i]) {
if (e != i && res[e]) win = true;
if (e == i && r[i]) win = true;
}
res[i] = win;
}
else {
for (auto &e : adj[i]) {
if (e != i && !res[e]) win = true;
if (e == i && !r[i]) win = true;
}
res[i] = !win;
}
}
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... |