#include "train.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 10;
int n , m , st;
vector <int> adj[N];
bool dead[N] , marked[N] , cyc[N];
void Dfs(int v)
{
marked[v] = true;
for(auto u : adj[v])
{
if(u == st)
cyc[st] = true;
if(!dead[u] && !marked[u])
Dfs(u);
}
}
bool Solve(int v)
{
marked[v] = true;
if(cyc[v])
return true;
bool flg = false;
for(auto u : adj[v]) if(!marked[u])
flg |= Solve(u);
return flg;
}
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
n = a.size();
m = u.size();
vector<int> res(a.size());
for(int i = 0 ; i < n ; i++)
dead[i] = r[i];
for(int i = 0 ; i < m ; i++)
adj[u[i]].push_back(v[i]);
for(int i = 0 ; i < n ; i++) if(!dead[i])
{
st = i;
for(int j = 0 ; j < n ; j++)
marked[j] = false;
Dfs(i);
}
for(int i = 0 ; i < n ; i++)
{
memset(marked , false , sizeof marked);
res[i] = Solve(i);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
860 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
109 ms |
1372 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
506 ms |
1140 KB |
3rd lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
724 ms |
1272 KB |
3rd lines differ - on the 2nd token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
860 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |