Submission #149394

# Submission time Handle Problem Language Result Execution time Memory
149394 2019-09-01T06:23:41 Z 1 WA = 5 Push Up(#3624, BaaaaaaaaaaaaaaaarkingDog, IohcEjnim, 0xrgb) Bulb Game (FXCUP4_bulb) C++17
100 / 100
94 ms 10032 KB
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;

int T;
vector <int> L, R;

int col[300010];
bool able[300010];
bool dummy;

void sub_tree(int x)
{
	if (L[x] >= 0) sub_tree(L[x]);
	if (R[x] >= 0) dummy = true, sub_tree(R[x]);

	col[x] = L[x] >= 0 ? col[L[x]] : L[x];
	
	able[x] = L[x] >= 0 ? able[L[x]] : false;
	if (R[x] == -2 || (R[x] >= 0 && col[R[x]] == -2)) able[x] = true;

	if (L[x] == -1 || (L[x] >= 0 && col[L[x]] == -1))
		if (R[x] == -1 || (R[x] >= 0 && col[R[x]] == -1))
			dummy = true;
}

bool main_line(int x)
{
	if (R[x] < 0) return true;
	
	sub_tree(R[x]);
	if (!able[R[x]]) return true;
	if (col[R[x]] == -2) return false;

	if (L[x] < 0) return dummy;
	return main_line(L[x]);
}

int FindWinner(int T_, std::vector<int> L_, std::vector<int> R_) {
	T = T_;
	L = L_; R = R_;

	int N = L.size();

	int x;
	for (x = 0; x >= 0; x = L[x]);
	if (x == -2) return 0;

	if (main_line(0)) return 1;
	return 0;
}

Compilation message

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:43:6: warning: unused variable 'N' [-Wunused-variable]
  int N = L.size();
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 508 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 508 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 72 ms 7456 KB Output is correct
28 Correct 85 ms 10032 KB Output is correct
29 Correct 89 ms 8812 KB Output is correct
30 Correct 72 ms 7408 KB Output is correct
31 Correct 74 ms 7416 KB Output is correct
32 Correct 94 ms 9612 KB Output is correct
33 Correct 91 ms 9952 KB Output is correct
34 Correct 90 ms 9952 KB Output is correct
35 Correct 89 ms 9180 KB Output is correct
36 Correct 90 ms 9508 KB Output is correct
37 Correct 89 ms 8876 KB Output is correct
38 Correct 88 ms 8824 KB Output is correct
39 Correct 91 ms 8812 KB Output is correct
40 Correct 88 ms 8872 KB Output is correct
41 Correct 87 ms 8860 KB Output is correct
42 Correct 87 ms 8796 KB Output is correct
43 Correct 89 ms 8928 KB Output is correct
44 Correct 89 ms 9140 KB Output is correct
45 Correct 90 ms 9056 KB Output is correct
46 Correct 89 ms 9328 KB Output is correct
47 Correct 74 ms 7324 KB Output is correct
48 Correct 73 ms 8096 KB Output is correct
49 Correct 76 ms 8032 KB Output is correct
50 Correct 76 ms 7456 KB Output is correct