Submission #150288

#TimeUsernameProblemLanguageResultExecution timeMemory
150288----MIT합격선---- (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms352 KiB
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> L, R;

int f(int x, int c) {
	if (c == 0) {
		if (x < 0) return 0;
		if (f(R[x], 1)) return 1;
		return f(L[x], c);
	}
	if (c == 1) {
		if (x < 0) return x == -1;
		if (f(R[x], 2) == 0) return 0;
		return f(L[x], 1);
	}
	if (c == 2) {
		if (x < 0) return x == -1;
		return f(L[x], 2);
	}
}

int FindWinner(int T, std::vector<int> LL, std::vector<int> RR){
	L = LL, R = RR;
	N = L.size();
	int x = 0;
	while (x >= 0) x = L[x];
	if (x == -2) return 0;
	return f(0, 0);
}

Compilation message (stderr)

bulb.cpp: In function 'int f(int, int)':
bulb.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...