# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151085 | kuroni | Bulb Game (FXCUP4_bulb) | C++17 | 76 ms | 6672 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 <cstdio>
using namespace std;
int dive(int u, vector<int> &l)
{
while (u >= 0)
u = l[u];
return u == -1;
}
int FindWinner(int t, vector<int> l, vector<int> r)
{
int n = l.size();
if (!dive(0, l))
return 0;
for (int u = 0; u >= 0; u = l[u])
if (!dive(r[u], l))
{
bool ok1 = false, ok2 = true;
for (int v = 0; v != l[u] && !ok1; v = l[v])
{
bool cur = true;
for (int k = r[v]; k >= 0; k = l[k])
if (!dive(r[k], l))
{
cur = false;
break;
}
ok1 |= cur;
}
if (r[u] >= 0)
{
swap(l[r[u]], r[r[u]]);
for (int v = 0; v >= 0; v = l[v])
if (!dive(r[v], l))
{
ok2 = false;
break;
}
swap(l[r[u]], r[r[u]]);
}
else
ok2 = false;
return ok1 || ok2;
}
return 1;
}
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... |