이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bulb.h"
#include <vector>
using namespace std;
vector<int> L, R;
int n;
bool vis[300001];
bool chB[300001];
bool res[300001];
bool inZ[300001];
void dfs(int x) {
if (vis[x]) return;
vis[x] = 1;
if (L[x] < 0) {
res[x] = L[x] == -2;
}
else {
dfs(L[x]);
res[x] = res[L[x]];
}
if (R[x] < 0) {
chB[x] = R[x] == -2;
}
else {
dfs(R[x]);
chB[x] = res[R[x]];
}
}
int FindWinner(int T, vector<int> _L, vector<int> _R) {
n = _L.size();
L = _L;
R = _R;
for (int x = 0; x < n; ++x) {
swap(L[x], R[x]);
int i;
for (i = 0; i < n; ++i) {
vis[i] = 0;
inZ[i] = 0;
}
for (int i = 0; i >= 0; i = L[i]) inZ[i] = 1;
dfs(0);
for (i = 0; i < n; ++i) {
if (inZ[i]) {
if (chB[i]) break;
}
else {
if (res[0]) break;
}
}
if (i == n) return 1;
swap(L[x], R[x]);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |