# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150657 | Ian and 2-bit memory (#200) | Bulb Game (FXCUP4_bulb) | C++17 | 2 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
bool red[300055];
void dfs(int v, vector<int> &L, vector<int> &R) {
if (v < 0) return;
if (L[v] == -1) {
red[v] = true;
}
dfs(L[v], L, R);
dfs(R[v], L, R);
if (L[v] >= 0) {
red[v] |= red[L[v]];
}
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
int N = L.size();
int v = 0;
vector<int> vec;
while (v >= 0) {
vec.push_back(v);
v = L[v];
}
if (v == -2) return 0;
dfs(0, L, R);
for (int i = 0; i < (int)vec.size(); i++) {
vector<int> temp;
for (int j = 0; j <= i; j++) {
temp.push_back(vec[j]);
}
temp.push_back(R[temp.back()]);
while (temp.back() >= 0) {
temp.push_back(L[temp.back()]);
}
if (temp.back() == -2 && temp.size() - 1 < N) continue;
bool bad = false;
for (int j = 0; j < (int)temp.size(); j++) {
if (j == i) continue;
if (temp[j] >= 0) {
if (R[temp[j]] == -2) {
bad = true;
break;
}
if (R[temp[j]] == -1) {
continue;
}
if (!red[R[temp[j]]]) {
bad = true;
break;
}
}
}
if (!bad) {
return 1;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |