Submission #150140

# Submission time Handle Problem Language Result Execution time Memory
150140 2019-09-01T07:47:29 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 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;
	int pos = 0;
    while(pos != RCOL)
    {
        if(!go_left(r[pos]))
        {
            return 0;
        }
        if(chk_route(r[pos]))
        {
            return 1;
        }
        pos = l[pos];
    }
	return 0;
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -