답안 #149315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149315 2019-09-01T06:13:43 Z test team(#3596, leesongun, einsu5, willi19) Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 376 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bulb.h"
#include "bulb.h"
#include<bits/stdc++.h>
using namespace std;
int l[300100],r[300100];
bool exist[300100];
vector<int> wen,owe;
void dfs(int node)
{
    
    if(owe[node]==-1)
    {
        r[node]=1;
        exist[node]=true;
    }
    if(owe[node]==-2)
        r[node]=2;
    if(owe[node]>=0)
    {
        dfs(owe[node]);
        r[node]=l[owe[node]];
    }
    if(wen[node]==-1)
        l[node]=1;
    if(wen[node]==-2)
        l[node]=2;
    if(wen[node]>=0)
    {
        dfs(wen[node]);
        l[node]=l[wen[node]];
        if(exist[node]==false&&exist[wen[node]])
            exist[node]=true;
    }
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
	int N = L.size();
	for(int i=0;i<N;i++)
    {
        wen.push_back(L[i]);
        owe.push_back(R[i]);
    }
    dfs(0);
    if(l[0]==1)
        return 1;
    int node=0,s=0;
    while(r[node]==2)
    {
        s++;
        if(owe[node]<0)
            return 0;
        if(exist[owe[node]]==false)
            return 0;
        if(wen[node]<0)
            break;
        node=wen[node];
    }
    if(r[node]==1)
    {
        if(s==N-1)
            return 1;
        if(owe[node]<0)
            return 0;
        if(exist[owe[node]]==false)
            return 0;
    }
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct