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 mxN = (int)5005;
vector<int>adj[mxN];
vector<bool>vis;
int t;
bool f;
vector<int>R;
bool dfs(int u) {
if(u == t && f)
return 1;
f = 1;
if(vis[u] || R[u])
return 0;
vis[u] = 1;
for(auto z : adj[u]) {
if(dfs(z))
return 1;
}
return 0;
}
vector<int>who_wins(vector<int>a, vector<int>r, vector<int>u, vector<int>v) {
R = r;
int n = r.size();
int m = u.size();
for(int i = 0 ; i < m ; i++)
adj[u[i]].push_back(v[i]);
vector<int>pos(n,0);
for(int i = 0 ; i < n ; i++) {
if(!r[i]) {
vis.clear();
vis.resize(n,0);
t = i;
f = 0;
pos[i] = dfs(i);
}
}
for(int x = 0 ; x < n ; x++)
for(int i = 0 ; i < n ; i++) {
for(auto z : adj[i])
pos[i] |= pos[z];
}
vector<int>ans(n);
for(int i = 0 ; i < n ; i++)
ans[i] = 1 - pos[i];
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... |