Submission #172647

# Submission time Handle Problem Language Result Execution time Memory
172647 2020-01-02T09:23:37 Z top34051 Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 376 KB
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;

const int maxn = 3e5 + 5;

int n, T;
vector<int> L, R;

int res[maxn], down[maxn];

void dfs(int u) {
	if(u < 0) return ;

	dfs(L[u]);
	dfs(R[u]);

	if(L[u] >= 0) res[u] = res[L[u]];
	else res[u] = (L[u] == -1);
	down[u] = (L[u] >= 0 ? down[L[u]] : 0) + 1;
}

int FindWinner(int turns, vector<int> leftChild, vector<int> rightChild){
	T = turns; L = leftChild; R = rightChild; 
	n = (int)leftChild.size();

	dfs(0);
	if(res[0] == 1 && down[0] < n) return 1;

	int x = 0;
	while(x >= 0) {
		if(R[x] >= 0 && res[R[x]] == 1) return 1;
		if(R[x] == -1) return 1;
		x = L[x];
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -