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, revAdj;
vector<bool> vst;
bool poss = false;
void dfs1(ll cur, ll root) {
vst[cur] = true;
for (auto &e : revAdj[cur]) {
if (e == root) poss = true;
if (vst[e]) continue;
dfs1(e, root);
}
}
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);
revAdj = vector<vector<ll>>(n);
for (int i = 0; i < m; i++) {
adj[u[i]].push_back(v[i]);
revAdj[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; i++) {
if (!r[i]) continue;
vst = vector<bool>(n);
poss = false;
dfs1(i, i);
if (poss) {
for (int j = 0; j < n; j++) {
if (!vst[j]) continue;
res[j] = true;
}
}
}
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... |