#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> ke[5001],ke2[5001],ke3[5001],d,A,R;
int n,m,vis[5001],p[5001],sz[5001],ch[5001];
stack <int> st;
queue <int> q;
int f(int u){
if (d[u]!=-1)
return d[u];
if (ch[u]&&A[u]==R[u])
return d[u]=A[u];
for (int v:ke[u])
if (v!=u)
return d[u]=f(v);
return d[u]=A[u]^1;
}
vector <int> who_wins(vector <int> a, vector <int> r, vector <int> u, vector <int> v){
A=a,R=r,n=a.size(),m=u.size();
for (int i=0;i<m;i++){
if (u[i]==v[i])
ch[u[i]]=1;
ke[u[i]].push_back(v[i]);
}
d.assign(n,-1);
for (int i=0;i<n;i++)
d[i]=f(i);
return d;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1116 KB |
Output is correct |
2 |
Correct |
3 ms |
1324 KB |
Output is correct |
3 |
Correct |
3 ms |
1112 KB |
Output is correct |
4 |
Correct |
3 ms |
1116 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
3 ms |
1116 KB |
Output is correct |
7 |
Correct |
3 ms |
1116 KB |
Output is correct |
8 |
Correct |
3 ms |
1116 KB |
Output is correct |
9 |
Correct |
3 ms |
1068 KB |
Output is correct |
10 |
Correct |
3 ms |
1116 KB |
Output is correct |
11 |
Correct |
3 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
219 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1372 KB |
Output is correct |
2 |
Correct |
5 ms |
1536 KB |
Output is correct |
3 |
Correct |
4 ms |
1372 KB |
Output is correct |
4 |
Runtime error |
212 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
213 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
216 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1116 KB |
Output is correct |
2 |
Correct |
3 ms |
1324 KB |
Output is correct |
3 |
Correct |
3 ms |
1112 KB |
Output is correct |
4 |
Correct |
3 ms |
1116 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
3 ms |
1116 KB |
Output is correct |
7 |
Correct |
3 ms |
1116 KB |
Output is correct |
8 |
Correct |
3 ms |
1116 KB |
Output is correct |
9 |
Correct |
3 ms |
1068 KB |
Output is correct |
10 |
Correct |
3 ms |
1116 KB |
Output is correct |
11 |
Correct |
3 ms |
1112 KB |
Output is correct |
12 |
Runtime error |
219 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Halted |
0 ms |
0 KB |
- |