#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];
bool vis[N][2];
void Dfs(int v , int ty)
{
vis[v][ty] = true;
if(dead[v] && ty == 0)
{
Dfs(v , 1);
return;
}
for(auto u : adj[v])
{
if(u == st && ty == 1)
cyc[st] = true;
if(!vis[u][ty])
Dfs(u , ty);
}
}
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])
{
//cout << "DFS " << i << endl;
st = i;
for(int j = 0 ; j < n ; j++)
vis[j][0] = vis[j][1] = false;
Dfs(i , 0);
}
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 |
185 ms |
1208 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
3rd lines differ - on the 8th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
1472 KB |
Output is correct |
2 |
Correct |
204 ms |
1368 KB |
Output is correct |
3 |
Correct |
171 ms |
1368 KB |
Output is correct |
4 |
Correct |
1060 ms |
1352 KB |
Output is correct |
5 |
Correct |
1049 ms |
1300 KB |
Output is correct |
6 |
Correct |
749 ms |
1112 KB |
Output is correct |
7 |
Correct |
197 ms |
1172 KB |
Output is correct |
8 |
Correct |
335 ms |
1116 KB |
Output is correct |
9 |
Correct |
319 ms |
1112 KB |
Output is correct |
10 |
Correct |
418 ms |
1112 KB |
Output is correct |
11 |
Incorrect |
369 ms |
1140 KB |
3rd lines differ - on the 89th token, expected: '1', found: '0' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
459 ms |
1360 KB |
3rd lines differ - on the 696th token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1398 ms |
1360 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 |
185 ms |
1208 KB |
3rd lines differ - on the 14th token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |