답안 #148940

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148940 2019-09-01T05:25:46 Z 모현보유국(#3693, jhnah917, stonejjun03, ahgus89) Bulb Game (FXCUP4_bulb) C++17
0 / 100
9 ms 7544 KB
#include "bulb.h"
#include <bits/stdc++.h>
using namespace std;

const int R = -1;
const int B = -2;
typedef pair<int, int> p;

vector<int> g[303030]; //R -1 B -2
p color[303030];

void dfs(int v){
	if(g[v][0] < 0){
		color[v].first = g[v][0];
	}else{
		dfs(g[v][0]);
		color[v].first = color[g[v][0]].first;
	}
	if(g[v][1] < 0){
		color[v].second = g[v][1];
	}else{
		dfs(g[v][1]);
		color[v].second = color[g[v][1]].first;
	}
}

bool chk(int v){
	//cout << v << " " << color[v].first << " " << color[v].second << "\n";
	if(color[v].first == R && color[v].second == R) return 1;
	if(color[v].first == B && color[v].second == B) return 0;
	if(color[v].first == R && color[v].second == B) return chk(g[v][1]);
	return 1;
}

int FindWinner(int T, std::vector<int> l, std::vector<int> r){
	int n = l.size();
	for(int i=0; i<n; i++){
		g[i].push_back(l[i]);
		g[i].push_back(r[i]);
	}
	dfs(0);
	if(color[0].first == B){
		return 0;
	}
	
	return chk(0);
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 9 ms 7544 KB Output is correct
4 Correct 9 ms 7516 KB Output is correct
5 Correct 8 ms 7544 KB Output is correct
6 Incorrect 9 ms 7416 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7388 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 9 ms 7544 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 9 ms 7544 KB Output is correct
6 Correct 9 ms 7516 KB Output is correct
7 Correct 8 ms 7544 KB Output is correct
8 Incorrect 9 ms 7416 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7388 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 9 ms 7544 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 9 ms 7544 KB Output is correct
6 Correct 9 ms 7516 KB Output is correct
7 Correct 8 ms 7544 KB Output is correct
8 Incorrect 9 ms 7416 KB Output isn't correct
9 Halted 0 ms 0 KB -