Submission #150416

#TimeUsernameProblemLanguageResultExecution timeMemory
150416Powered By Zigui (#200)Bulb Game (FXCUP4_bulb)C++17
Compilation error
0 ms0 KiB
#include "bulb.h"
#include <algorithm>
#include <string.h>
using namespace std;

const int BCOL = 200001;
const int RCOL = 200002;
int l[200003], r[200003], par[200003];
int go_left_chk[200003];
int chk_route_dp[200003];
int color[200003];
int go_left(int x)
{
    int& ret = go_left_chk[x];
    if(~ret) return ret;
    if(x == BCOL) return ret = 0;
    else if(x == RCOL) return ret = 1;
    return ret = go_left(l[x]);
}
int chk_route(int x)
{
    int& ret = chk_route_dp[x];
    if(x == BCOL) return ret = 0;
    else if(x == RCOL) return ret = 1;
    return ret = (chk_route(l[x]) && go_left(r[x]));
}
int chk_exception(int x)
{
    if(x == BCOL || x == RCOL)
    {
        return 1;
    }
    return chk_exception(l[x]) && r[x] == RCOL);
}
int FindWinner(int T, std::vector<int> L, std::vector<int> R){
    memset(go_left_chk, -1, sizeof(go_left_chk));
    memset(chk_route_dp, -1, sizeof(chk_route_dp));
	int N = L.size();
	for(int i=0;i<N;i++)
	{
	    l[i] = (L[i] >= 0 ? L[i] : 200003 + L[i]);
	    r[i] = (R[i] >= 0 ? R[i] : 200003 + R[i]);
	}
	if(!go_left(0)) return 0;
	if(N == 1) return 1;
	int cnt = 0;
	int pos = 0;
    while(pos != RCOL)
    {
        if(!cnt && chk_exception(r[pos]) && l[pos] >= BCOL)
        {
            return 1;
        }
        if(!go_left(r[pos]))
        {
            return 0;
        }
        if(chk_route(r[pos]))
        {
            return 1;
        }
        if(r[pos] < BCOL) cnt++;
        pos = l[pos];
    }
	return 0;
}

Compilation message (stderr)

bulb.cpp: In function 'int chk_exception(int)':
bulb.cpp:33:47: error: expected ';' before ')' token
     return chk_exception(l[x]) && r[x] == RCOL);
                                               ^
bulb.cpp:33:47: error: expected primary-expression before ')' token