# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
150203 | | JeffreyHo (#200) | Bulb Game (FXCUP4_bulb) | C++17 | | 1032 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"
using namespace std;
int l[300005], r[300005], c[300005], d[300005], e[300005], f[300005], o;
int t[600005], z;
int que(int l, int r) {
int z = 890328;
for (l += o, r += o; l < r; l >>= 1, r >>= 1) {
if (l & 1) z = min(z, t[l++]);
if (r & 1) z = min(z, t[--r]);
}
return z;
}
void dfs(int x) {
d[x] = o;
if (l[x] >= 0) c[l[x]] = c[x], dfs(l[x]);
if (l[x] == -2) f[o++] = c[x];
if (r[x] >= 0) c[r[x]] = c[x] + 1, dfs(r[x]);
if (r[x] == -2) f[o++] = c[x] + 1;
e[x] = o;
}
void dfs2(int x) {
if (que(0, d[x]) >= 2 && que(d[x], e[x]) >= 3 && que(e[x], o) >= 2) z = 1;
if (l[x] >= 0) dfs2(l[x]);
if (r[x] >= 0) dfs2(r[x]);
}
int FindWinner(int k, std::vector<int> L, std::vector<int> R) {
if (k == 1) while (1);
int n = (int)L.size();
for (int i = 0; i < n; i++) l[i] = L[i], r[i] = R[i];
dfs(0);
//for (int i = 0; i < n; i++) printf("%d %d %d\n", c[i], d[i], e[i]);
for (int i = 0; i < o; i++) t[i + o] = f[i];
for (int i = o - 1; i > 0; i--) t[i] = min(t[i << 1], t[i << 1 | 1]);
//for (int i = 0; i < o + o; i++) printf("%d ", t[i]);
//printf("%d\n", que(0, 2));
dfs2(0);
return z;
}
Compilation message (stderr)
bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:33:17: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
if (k == 1) while (1);
^~~~~
bulb.cpp:34:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
int n = (int)L.size();
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |