답안 #150298

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150298 2019-09-01T08:05:22 Z Powered By Zigui(#3580, aaaa, evenharder, best_sheild97) Bulb Game (FXCUP4_bulb) C++17
0 / 100
3 ms 1912 KB
#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]) && (go_left(r[x]));
}
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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1912 KB Output is correct
2 Incorrect 3 ms 1912 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1888 KB Output is correct
2 Correct 3 ms 1912 KB Output is correct
3 Correct 3 ms 1912 KB Output is correct
4 Incorrect 3 ms 1912 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1888 KB Output is correct
2 Correct 3 ms 1912 KB Output is correct
3 Correct 3 ms 1912 KB Output is correct
4 Incorrect 3 ms 1912 KB Output isn't correct
5 Halted 0 ms 0 KB -