#include <bits/stdc++.h>
#include "train.h"
using namespace std;
vector<int>tim;
vector<bool>vis(15);
vector<int>s,a,r;
vector<int>adj[15];
vector<int>ans(15,2);
int t = 1;
bool dfs(int u) {
vis[u] = 1;
tim[u] = t++;
if(r[u])
s.push_back(t-1);
bool ok;
if(a[u]) {
ok = 0;
for(auto z : adj[u]) if(!vis[z]) {
ok |= dfs(z);
if(ok)
break;
} else {
if(!s.empty() && tim[z] <= s.back())
ok = 1;
}
} else {
ok = 1;
for(auto z : adj[u]) if(!vis[z]) {
ok &= dfs(z);
if(!ok)
break;
} else {
if(!s.empty() && tim[z] <= s.back())
ok &= 1;
else
ok = 0;
}
}
if(r[u])
s.pop_back();
tim[u] = 0;
vis[u] = 0;
return ok;
}
vector<int>who_wins(vector<int>A, vector<int>R, vector<int>u, vector<int>v) {
r = R;
a = A;
int n = r.size();
int m = u.size();
for(int i = 0 ; i < m ; i++) {
adj[u[i]].push_back(v[i]);
}
for(int y = 0 ; y < n ; y++) {
int i = y;
t = 1;
tim.clear();
tim.resize(n,0);
ans[i] = dfs(i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
300 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
1236 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
1108 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 ms |
1236 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
852 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |