#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> p;
vector<bool> vis(N);
auto dfs = [&](auto dfs, int x) -> int {
p.push_back(x);
vis[x] = 1;
for (int y : adj[x]) {
if (!vis[y]) {
if (dfs(dfs, y) == A[x]) {
return A[x];
}
} else {
int cyc = 0;
for (int i = p.size() - 1; i >= 0; i--) {
cyc |= R[p[i]];
if (p[i] == y) {
break;
}
}
if (A[x] == cyc) {
return A[x];
}
}
}
vis[x] = 0;
p.pop_back();
return 1 - A[x];
};
ans[i] = dfs(dfs, i);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
724 KB |
3rd lines differ - on the 141st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '0', found: '1' |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2068 ms |
1068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2067 ms |
1156 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2056 ms |
1120 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
724 KB |
3rd lines differ - on the 141st token, expected: '0', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |