Submission #150789

# Submission time Handle Problem Language Result Execution time Memory
150789 2019-09-01T08:56:07 Z 먀(#3635, khsoo01) Bulb Game (FXCUP4_bulb) C++17
36 / 100
87 ms 10040 KB
#include "bulb.h"
#include<bits/stdc++.h>
using namespace std;

const int N = 300005;

int n, ans[N][2], d[N];
vector<int> l, r;

bool ini[N];

bool getini (int I) {
	if(I < 0) return I == -1;
	return ini[I];
}

bool solve (int I, int V) {
	if(V < 0) return false;
	if(I < 0) return (V == 0);
	if(ans[I][V]) return ans[I][V] - 1;
	if(getini(r[I])) ans[I][V] |= solve(l[I], V);
	if(getini(l[I])) ans[I][V] |= solve(r[I], V-1);
	ans[I][V]++;
	return ans[I][V] - 1;
}

void calc (int I, int D) {
	if(I < 0) return;
	calc(l[I], D);
	calc(r[I], D+1);
	ini[I] = getini(l[I]);
	d[I] = D;
}

int FindWinner(int T, vector<int> L, vector<int> R){
	n = L.size();
	l = L; r = R;
	calc(0, 0);
	if(solve(0, 1)) return true;
	for(int i=0;i<n;i++) {
		if(d[i] > 1) return solve(0, 0);
	}
	return false;
}
# 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 348 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 348 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 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 348 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 348 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 2 ms 424 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 376 KB Output is correct
22 Correct 2 ms 348 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 348 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 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 348 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 348 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 2 ms 424 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 376 KB Output is correct
22 Correct 2 ms 348 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 348 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Incorrect 87 ms 10040 KB Output isn't correct
28 Halted 0 ms 0 KB -