Submission #149918

# Submission time Handle Problem Language Result Execution time Memory
149918 2019-09-01T07:23:49 Z 잉여로운 고3(#3749, imyujin, sebinkim) Bulb Game (FXCUP4_bulb) C++17
100 / 100
109 ms 37880 KB
#include <bits/stdc++.h>

#include "bulb.h"

using namespace std;

typedef tuple <int, int, int, int, int> tii;

vector <int> L, R;
int n;

tii dfs(int p)
{
	int d0, d1, d2, d3, s;
	int l0, l1, l2, l3, ls;
	int r0, r1, r2, r3, rs;
	
	if(p < 0) d0 = -p, d1 = d2 = d3 = s = 0;
	else{
		tie(l0, l1, l2, l3, ls) = dfs(L[p]);
		tie(r0, r1, r2, r3, rs) = dfs(R[p]);
		s = ls + rs + 1;
		
		d0 = l0;
		
		d1 = l1 | r0;
		if(rs) d1 |= l0;
		
		d2 = l2 | r0;
		if(rs) d2 |= l0;
		
		d3 = d0;
		if(d0 == 1){
			if((l1 & 1) && !(l3 & 2) && r0 != 2) {}
			else if(!(r2 & 2)) {}
			else if(rs && !(l2 & 2) && (r1 & 1)) {}
			else d3 |= 2;
		}
		else{
			if((l1 & 2) && !(l3 & 1) && r0 != 1) {}
			else if(!(r2 & 1)) {}
			else if(rs && !(l2 & 1) && (r1 & 2)) {}
			else d3 |= 1;
		}
	}
	
	return tii(d0, d1, d2, d3, s);
}

int FindWinner(int T, vector <int> _L, vector<int> _R)
{
	n = L.size(); swap(L, _L); swap(R, _R);
	
	int d0, d1, d2, d3, s;
	
	tie(d0, d1, d2, d3, s) = dfs(0);
	
	if(d3 & 2) return 0;
	else return 1;
}
# 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 300 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 256 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 300 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 256 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 2 ms 376 KB Output is correct
19 Correct 2 ms 476 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 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 380 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 300 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 256 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 2 ms 376 KB Output is correct
19 Correct 2 ms 476 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 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 380 KB Output is correct
27 Correct 84 ms 5056 KB Output is correct
28 Correct 82 ms 5072 KB Output is correct
29 Correct 84 ms 5072 KB Output is correct
30 Correct 109 ms 37880 KB Output is correct
31 Correct 109 ms 37824 KB Output is correct
32 Correct 85 ms 4984 KB Output is correct
33 Correct 87 ms 5148 KB Output is correct
34 Correct 86 ms 5020 KB Output is correct
35 Correct 87 ms 5012 KB Output is correct
36 Correct 87 ms 4984 KB Output is correct
37 Correct 86 ms 5060 KB Output is correct
38 Correct 85 ms 4956 KB Output is correct
39 Correct 86 ms 5020 KB Output is correct
40 Correct 86 ms 5072 KB Output is correct
41 Correct 86 ms 5016 KB Output is correct
42 Correct 87 ms 5068 KB Output is correct
43 Correct 85 ms 5068 KB Output is correct
44 Correct 86 ms 4956 KB Output is correct
45 Correct 86 ms 5024 KB Output is correct
46 Correct 86 ms 4984 KB Output is correct
47 Correct 92 ms 12280 KB Output is correct
48 Correct 93 ms 12368 KB Output is correct
49 Correct 93 ms 12280 KB Output is correct
50 Correct 92 ms 12316 KB Output is correct