답안 #149059

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149059 2019-09-01T05:39:23 Z CHT를 사랑하는 모임(#3587, moonrabbit2, Retro3014, gs18115) Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 504 KB
#include "bulb.h"
#include <bits/stdc++.h>

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 300010;

int l[MAX_N+1], r[MAX_N+1];
int N, T;
int l2[MAX_N+1];
int r2[MAX_N+1];
bool dp1[MAX_N+1];

void dfs(int x){
	if(r[x]>=0){
		dfs(r[x]);
		r2[x] = l2[r[x]];
	}else{
		r2[x] = -r[x];
	}
	if(l[x]>=0){
		dfs(l[x]);
		l2[x] = l2[l[x]];
		dp1[x] = (dp1[l[x]] & (r2[x]==1)); 
	}else{
		l2[x] = -l[x];
		dp1[x] = (r2[x]==1);
	}
	


}

bool dfs2(int x){
	if(r[x]>=0){
		if(dp1[r[x]] && (r2[x]==1)){
			return true;
		}
	}else{
		if(r2[x]==1){
			return true;
		}
	}
	if(r2[x]==1 &&  l[x]>=0){
		return dfs2(l[x]);
	}
	return false;
}

int FindWinner(int t, vector<int> L, vector<int> R){
	N = R.size(); T = t;
	for(int i=0; i<N; i++){
		l[i] = L[i]; r[i] = R[i];
	}
	dfs(0);
	if(l2[0]==2){
		return 0;
	}
	bool b = dfs2(0);
	return b;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -