#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> U, vector<int> V) {
int N = A.size();
int M = U.size();
vector<vector<int>> adj(N);
for (int i = 0; i < M; i++) {
adj[U[i]].push_back(V[i]);
}
vector<int> ans(N);
for (int i = 0; i < N; i++) {
vector<int> pos(N, -1), c{-1};
int t = 0;
auto dfs = [&](auto dfs, int x) -> int {
pos[x] = t++;
if (R[x]) {
c.push_back(pos[x]);
}
for (int y : adj[x]) {
if (pos[y] == -1) {
if (dfs(dfs, y)) {
return 1;
}
} else {
if (pos[y] <= c.back()) {
return 1;
}
}
}
pos[x] = -1; t--;
if (R[x]) {
c.pop_back();
}
return 0;
};
ans[i] = dfs(dfs, i);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
852 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 |
1 ms |
212 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 |
Execution timed out |
2078 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
1096 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 |
11 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 |
7 ms |
852 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |