This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5555;
int n, m;
vector<int> a, r;
vector<int> g[N];
bool ans = false;
int used[N];
int cntR[N];
int currR = 0;
void dfs(int v) {
used[v] = 1;
cntR[v] = currR;
currR += r[v];
for (int to : g[v]) {
if (used[to] == 1) {
if (cntR[to] != currR) ans = true;
}
else if (used[to] == 0) {
dfs(to);
}
}
used[v] = 2;
}
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) {
n = A.size(), m = u.size();
a = A, r = R;
for (int i = 0; i < m; i ++) {
g[u[i]].push_back(v[i]);
}
vector<int> res;
for (int s = 0; s < n; s ++) {
ans = false;
for (int i = 0; i < n; i ++) used[i] = 0;
dfs(s);
res.push_back(ans);
}
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... |