Submission #149396

# Submission time Handle Problem Language Result Execution time Memory
149396 2019-09-01T06:23:44 Z 강력한 한방 필살기(#3595, gs14004, kriii, OnionPringles) Bulb Game (FXCUP4_bulb) C++17
100 / 100
98 ms 16580 KB
#include "bulb.h"

#include<stdio.h>
using namespace std;
const int N=301010;

int lblue[N],rlblue[N],lrlblue[N];
vector<int> L, R;
void dfs(int u){
	if(L[u]>=0){
		dfs(L[u]);
		lblue[u]=lblue[L[u]];
	}
	else if(L[u]==-2)lblue[u]=1;
	if(R[u]>=0){
		dfs(R[u]);
		rlblue[u]=lblue[R[u]];
	}
	else if(R[u]==-2)rlblue[u]=1;
	lrlblue[u]=rlblue[u];
	if(L[u]>=0)lrlblue[u]|=lrlblue[L[u]];
}

int chk[N];

int FindWinner(int T, std::vector<int> L, std::vector<int> R){
	::L=L,::R=R;
	int n = L.size();
	int cur = 0;
	while(cur>=0)cur=L[cur];
	if(cur==-2)return 0;
	cur=0;
	int curlr=0;
	dfs(0);
	while(cur>=0){
		bool bad=false;
		if(R[cur]>=0&&lrlblue[R[cur]])bad=true;
		if(curlr)bad=true;
		if(!bad)return 1;
		curlr|=rlblue[cur];
		cur=L[cur];
	}
	cur=0,curlr=0;
	while(cur>=0){
		chk[cur]=1;
		if(R[cur]>=0){
			int cur2=R[cur];
			while(cur2>=0){
				chk[cur2]=1;
				bool bad=false;
				if(rlblue[cur2])bad=true;
				if(curlr)bad=true;
				if(L[cur]>=0&&lrlblue[L[cur]])bad=true;
				if(!bad)return 1;
				cur2=L[cur2];
			}
		}
		curlr|=rlblue[cur];
		cur=L[cur];
	}
	int cnt=0;
	for(int i=0;i<n;i++)if(chk[i])cnt++;
	if(cnt!=n){
		if(!lrlblue[0])return 1;
	}
	
	return 0;
}
# 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 348 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 348 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 348 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 348 KB Output is correct
19 Correct 2 ms 368 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 380 KB Output is correct
24 Correct 2 ms 380 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 348 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 348 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 348 KB Output is correct
19 Correct 2 ms 368 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 380 KB Output is correct
24 Correct 2 ms 380 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 8372 KB Output is correct
28 Correct 88 ms 12092 KB Output is correct
29 Correct 92 ms 11984 KB Output is correct
30 Correct 92 ms 16160 KB Output is correct
31 Correct 96 ms 16580 KB Output is correct
32 Correct 91 ms 11612 KB Output is correct
33 Correct 91 ms 11856 KB Output is correct
34 Correct 91 ms 12124 KB Output is correct
35 Correct 97 ms 11752 KB Output is correct
36 Correct 90 ms 12664 KB Output is correct
37 Correct 92 ms 12340 KB Output is correct
38 Correct 91 ms 12280 KB Output is correct
39 Correct 91 ms 12544 KB Output is correct
40 Correct 92 ms 11588 KB Output is correct
41 Correct 91 ms 11748 KB Output is correct
42 Correct 94 ms 12692 KB Output is correct
43 Correct 91 ms 12684 KB Output is correct
44 Correct 98 ms 12576 KB Output is correct
45 Correct 95 ms 11948 KB Output is correct
46 Correct 89 ms 12280 KB Output is correct
47 Correct 91 ms 12444 KB Output is correct
48 Correct 90 ms 13048 KB Output is correct
49 Correct 90 ms 13092 KB Output is correct
50 Correct 91 ms 11936 KB Output is correct