# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
151085 |
2019-09-01T17:10:17 Z |
kuroni |
Bulb Game (FXCUP4_bulb) |
C++17 |
|
76 ms |
6672 KB |
#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
bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:14:6: warning: unused variable 'n' [-Wunused-variable]
int n = l.size();
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
276 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
292 KB |
Output is correct |
23 |
Correct |
2 ms |
392 KB |
Output is correct |
24 |
Correct |
2 ms |
256 KB |
Output is correct |
25 |
Correct |
2 ms |
356 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
276 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
380 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
292 KB |
Output is correct |
23 |
Correct |
2 ms |
392 KB |
Output is correct |
24 |
Correct |
2 ms |
256 KB |
Output is correct |
25 |
Correct |
2 ms |
356 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
70 ms |
6540 KB |
Output is correct |
28 |
Correct |
70 ms |
6032 KB |
Output is correct |
29 |
Correct |
71 ms |
6156 KB |
Output is correct |
30 |
Correct |
71 ms |
5808 KB |
Output is correct |
31 |
Correct |
70 ms |
5468 KB |
Output is correct |
32 |
Correct |
70 ms |
5788 KB |
Output is correct |
33 |
Correct |
70 ms |
6408 KB |
Output is correct |
34 |
Correct |
71 ms |
6672 KB |
Output is correct |
35 |
Correct |
70 ms |
5756 KB |
Output is correct |
36 |
Correct |
70 ms |
6156 KB |
Output is correct |
37 |
Correct |
71 ms |
5888 KB |
Output is correct |
38 |
Correct |
70 ms |
6156 KB |
Output is correct |
39 |
Correct |
70 ms |
6236 KB |
Output is correct |
40 |
Correct |
69 ms |
5636 KB |
Output is correct |
41 |
Correct |
70 ms |
5508 KB |
Output is correct |
42 |
Correct |
71 ms |
6156 KB |
Output is correct |
43 |
Correct |
70 ms |
6388 KB |
Output is correct |
44 |
Correct |
70 ms |
6168 KB |
Output is correct |
45 |
Correct |
70 ms |
5904 KB |
Output is correct |
46 |
Correct |
76 ms |
6160 KB |
Output is correct |
47 |
Correct |
70 ms |
5500 KB |
Output is correct |
48 |
Correct |
73 ms |
6152 KB |
Output is correct |
49 |
Correct |
72 ms |
6204 KB |
Output is correct |
50 |
Correct |
72 ms |
5056 KB |
Output is correct |