#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300100;
int N;
int L[MAXN], R[MAXN];
vector <int> vs;
vector <int> hs;
int llim;
bool bbad[MAXN], hbad[MAXN];
bool bfull;
int nc[MAXN];
void flood (int cloc, int cdep)
{
nc[cloc] = vs.size();
if (cloc < 0)
{
if (cloc == -2)
{
if (vs.size() > 2)
return;
if (vs.size() == 0)
{
// gg
llim = -100;
}
else if (vs.size() == 1)
{
// can't intercept after, or at unless this is the full path
if (cdep == N)
{
// must go at or before here
llim = min (llim, vs[0]);
}
else
{
// must go before here
llim = min (llim, vs[0] - 1);
}
}
else
{
int lo = hs[0], hi = hs[1];
hbad[lo] = hbad[hi] = true;
}
}
return;
}
flood (L[cloc], cdep + 1);
vs.push_back(cdep);
hs.push_back(cloc);
flood (R[cloc], cdep + 1);
vs.pop_back();
hs.pop_back();
}
int FindWinner(int T, std::vector<int> vl, std::vector<int> vr){
N = vl.size();
for (int i = 0; i < N; i++)
{
L[i] = vl[i];
R[i] = vr[i];
}
for (int i = 0; i < MAXN; i++)
{
bbad[i] = hbad[i] = false;
nc[i] = 0;
}
for (int i = 0; i < N; i++)
{
L[i] = vl[i];
R[i] = vr[i];
}
llim = 1e9;
flood (0, 0);
int cloc = 0, cdep = 0;
while (cloc >= 0)
{
if (!hbad[cloc] && cdep <= llim)
return 1;
cloc = L[cloc];
cdep++;
}
if (llim < 1e6)
return 0;
for (int i = 0; i < N; i++)
if (nc[i] >= 2 && !hbad[i])
return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2168 KB |
Output is correct |
2 |
Correct |
4 ms |
2040 KB |
Output is correct |
3 |
Correct |
4 ms |
2040 KB |
Output is correct |
4 |
Correct |
4 ms |
2168 KB |
Output is correct |
5 |
Correct |
4 ms |
2168 KB |
Output is correct |
6 |
Correct |
4 ms |
2084 KB |
Output is correct |
7 |
Correct |
4 ms |
2168 KB |
Output is correct |
8 |
Correct |
4 ms |
2040 KB |
Output is correct |
9 |
Correct |
4 ms |
2040 KB |
Output is correct |
10 |
Correct |
4 ms |
2040 KB |
Output is correct |
11 |
Correct |
4 ms |
2140 KB |
Output is correct |
12 |
Correct |
4 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2040 KB |
Output is correct |
2 |
Correct |
3 ms |
2040 KB |
Output is correct |
3 |
Correct |
4 ms |
2168 KB |
Output is correct |
4 |
Correct |
4 ms |
2040 KB |
Output is correct |
5 |
Correct |
4 ms |
2040 KB |
Output is correct |
6 |
Correct |
4 ms |
2168 KB |
Output is correct |
7 |
Correct |
4 ms |
2168 KB |
Output is correct |
8 |
Correct |
4 ms |
2084 KB |
Output is correct |
9 |
Correct |
4 ms |
2168 KB |
Output is correct |
10 |
Correct |
4 ms |
2040 KB |
Output is correct |
11 |
Correct |
4 ms |
2040 KB |
Output is correct |
12 |
Correct |
4 ms |
2040 KB |
Output is correct |
13 |
Correct |
4 ms |
2140 KB |
Output is correct |
14 |
Correct |
4 ms |
2140 KB |
Output is correct |
15 |
Correct |
4 ms |
2168 KB |
Output is correct |
16 |
Correct |
4 ms |
2044 KB |
Output is correct |
17 |
Correct |
4 ms |
2040 KB |
Output is correct |
18 |
Correct |
4 ms |
2168 KB |
Output is correct |
19 |
Correct |
4 ms |
2164 KB |
Output is correct |
20 |
Correct |
4 ms |
2040 KB |
Output is correct |
21 |
Correct |
4 ms |
2140 KB |
Output is correct |
22 |
Correct |
4 ms |
2040 KB |
Output is correct |
23 |
Correct |
4 ms |
2140 KB |
Output is correct |
24 |
Correct |
4 ms |
2088 KB |
Output is correct |
25 |
Correct |
4 ms |
2168 KB |
Output is correct |
26 |
Correct |
4 ms |
2144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2040 KB |
Output is correct |
2 |
Correct |
3 ms |
2040 KB |
Output is correct |
3 |
Correct |
4 ms |
2168 KB |
Output is correct |
4 |
Correct |
4 ms |
2040 KB |
Output is correct |
5 |
Correct |
4 ms |
2040 KB |
Output is correct |
6 |
Correct |
4 ms |
2168 KB |
Output is correct |
7 |
Correct |
4 ms |
2168 KB |
Output is correct |
8 |
Correct |
4 ms |
2084 KB |
Output is correct |
9 |
Correct |
4 ms |
2168 KB |
Output is correct |
10 |
Correct |
4 ms |
2040 KB |
Output is correct |
11 |
Correct |
4 ms |
2040 KB |
Output is correct |
12 |
Correct |
4 ms |
2040 KB |
Output is correct |
13 |
Correct |
4 ms |
2140 KB |
Output is correct |
14 |
Correct |
4 ms |
2140 KB |
Output is correct |
15 |
Correct |
4 ms |
2168 KB |
Output is correct |
16 |
Correct |
4 ms |
2044 KB |
Output is correct |
17 |
Correct |
4 ms |
2040 KB |
Output is correct |
18 |
Correct |
4 ms |
2168 KB |
Output is correct |
19 |
Correct |
4 ms |
2164 KB |
Output is correct |
20 |
Correct |
4 ms |
2040 KB |
Output is correct |
21 |
Correct |
4 ms |
2140 KB |
Output is correct |
22 |
Correct |
4 ms |
2040 KB |
Output is correct |
23 |
Correct |
4 ms |
2140 KB |
Output is correct |
24 |
Correct |
4 ms |
2088 KB |
Output is correct |
25 |
Correct |
4 ms |
2168 KB |
Output is correct |
26 |
Correct |
4 ms |
2144 KB |
Output is correct |
27 |
Correct |
95 ms |
9124 KB |
Output is correct |
28 |
Correct |
96 ms |
9308 KB |
Output is correct |
29 |
Correct |
97 ms |
9260 KB |
Output is correct |
30 |
Correct |
103 ms |
18688 KB |
Output is correct |
31 |
Correct |
102 ms |
18668 KB |
Output is correct |
32 |
Correct |
95 ms |
9304 KB |
Output is correct |
33 |
Correct |
96 ms |
9296 KB |
Output is correct |
34 |
Correct |
96 ms |
9300 KB |
Output is correct |
35 |
Correct |
97 ms |
9208 KB |
Output is correct |
36 |
Correct |
97 ms |
9256 KB |
Output is correct |
37 |
Correct |
96 ms |
9308 KB |
Output is correct |
38 |
Correct |
96 ms |
9312 KB |
Output is correct |
39 |
Correct |
95 ms |
9304 KB |
Output is correct |
40 |
Correct |
94 ms |
9080 KB |
Output is correct |
41 |
Correct |
94 ms |
9124 KB |
Output is correct |
42 |
Correct |
93 ms |
9128 KB |
Output is correct |
43 |
Correct |
95 ms |
9180 KB |
Output is correct |
44 |
Correct |
95 ms |
9172 KB |
Output is correct |
45 |
Correct |
95 ms |
9052 KB |
Output is correct |
46 |
Correct |
94 ms |
9080 KB |
Output is correct |
47 |
Correct |
97 ms |
11180 KB |
Output is correct |
48 |
Correct |
97 ms |
11260 KB |
Output is correct |
49 |
Correct |
98 ms |
11256 KB |
Output is correct |
50 |
Correct |
97 ms |
11228 KB |
Output is correct |