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;
const int MAX_N = 5005;
const int MAX_M = 20005;
int N, M;
vector <int> graph[MAX_N];
int A[MAX_N], R[MAX_N];
bool visited[MAX_N];
bool dfs(int u, int x, bool found, bool init = false) {
// cout << x << " : " << u << ' ' << found << endl;
if (u == x and init == true) return found;
if (visited[u] == true) return false;
init = true;
visited[u] = true;
if (R[u] == 1) found = true;
for (auto v : graph[u]) if (dfs(v, x, found, true) == true) return true;
return false;
}
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v) {
N = a.size(), M = u.size();
for (int i = 0; i < N; i++) A[i] = a[i], R[i] = r[i];
for (int i = 0; i < M; i++) graph[u[i]].push_back(v[i]);
vector <int> ans;
for (int s = 0; s < N; s++) {
for (int i = 0; i < N; i++) visited[i] = false;
ans.push_back(dfs(s, s, false));
}
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... |