Submission #148740

# Submission time Handle Problem Language Result Execution time Memory
148740 2019-09-01T05:01:26 Z test team(#3596, leesongun, einsu5, willi19) Bulb Game (FXCUP4_bulb) C++17
0 / 100
260 ms 262148 KB
#include "bulb.h"
#include<bits/stdc++.h>
using namespace std;
int l[300100],r[300100];
vector<int> wen,owe;
void dfs(int node)
{
    if(wen[node]==-1)
        l[node]=1;
    if(wen[node]==-2)
        l[node]=2;
    else
    {
        dfs(wen[node]);
        l[node]=l[wen[node]];
    }
    if(owe[node]==-1)
        r[node]=1;
    if(owe[node]==-2)
        r[node]=2;
    else
    {
        dfs(owe[node]);
        r[node]=l[owe[node]];
    }
}
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 0;
    int first=0,node=0;
    while(r[node]==2)
    {
        if(wen[node]<0)
            return 1;
        node=wen[node];
    }
    if(owe[node]<0)
        return 1;
    node=owe[node];
    while(r[node]==2)
    {
        if(wen[node]<0)
            return 1;
        node=wen[node];
    }
    return 0;
}

Compilation message

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:37:9: warning: unused variable 'first' [-Wunused-variable]
     int first=0,node=0;
         ^~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 260 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 234 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 234 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -