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>
using namespace std;
vector<int> g[5005];
bool loop[5005];
bool rech[5005];
bool dfs(int u){
if(g[u].empty()) return loop[u] && rech[u];
for(int x : g[u]) if(dfs(x)) return true;
return loop[u] && rech[u];
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
// Subtask 1
int m = u.size();
for(int i = 0; i < m; i++){
if(u[i] == v[i]) loop[u[i]] = true;
else g[u[i]].push_back(v[i]);
}
int n = a.size();
for(int i = 0; i < n; i++){
rech[i] = r[i] != 0;
}
vector<int> res;
for(int i = 0; i < n; i++){
res.push_back(dfs(i));
}
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... |