답안 #148680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148680 2019-09-01T04:54:53 Z (παρα)γεμιστά(#3619, cfalas, ctziapo, Charis02) Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 376 KB
#include "bulb.h"
#include<vector>
#include<iostream>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define MAXN 300004

using namespace std;

int N;
int root = 0;
vector < int > Ls,Rs;
vector < bool > blues(MAXN);

bool whowins(int cur)
{
    if(cur==-1)
        return 1;
    else if(cur==-2)
        return 0;

    return whowins(Rs[cur]);
}

void init(int cur,int cntleft,int left1,int left2)
{
    if(cntleft > 2)
        return;
    if(cur == -1)
    {
        return;
    }
    else if(cur == -2)
    {
        if(cntleft == 1)
        {
            blues[left1] = true;
        }
        else if(cntleft == 2)
        {
            blues[left1] = true;
            blues[left2] = true;
        }

        return;
    }

    init(Rs[cur],cntleft,left1,left2);

    if(cntleft == 0)
        left1 = cur;
    else
        left2 = cur;

    init(Ls[cur],cntleft,left1,left2);
    return;
}

int FindWinner(int T, std::vector<int> L, std::vector<int> R){
	N = L.size();

	Ls = L;
	Rs = R;

    if(whowins(root))
    {
        init(0,0,N,N);
        bool found = false;

        rep(i,0,N)
        {
            if(!blues[i])
            {
                found=true;
                break;
            }
        }

        return found;
    }
    else
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 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 -