#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 (A[u]){
if (ch[u]&&R[u])
return d[u]=1;
if (ch[u]&&ke[u].size()==1)
return d[u]=0;
return d[u]=f(ke[u][0]);
}
if (ch[u]&&!R[u])
return d[u]=0;
if (ch[u]&&ke[u].size()==1)
return d[u]=1;
return d[u]=f(ke[u][0]);
}
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;
ke3[v[i]].push_back(u[i]);
ke[u[i]].push_back(v[i]);
ke2[v[i]].push_back(u[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 |
Runtime error |
212 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
215 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1880 KB |
Output is correct |
2 |
Correct |
5 ms |
1880 KB |
Output is correct |
3 |
Correct |
6 ms |
1884 KB |
Output is correct |
4 |
Runtime error |
220 ms |
262144 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
220 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
217 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
212 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |