답안 #150560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150560 2019-09-01T08:38:43 Z Greedy left the chat.(#3618, miguel, claudy, MvC) Bulb Game (FXCUP4_bulb) C++17
0 / 100
2 ms 504 KB
#include "bulb.h"
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=3e5+50;
const int mod=1e9+7;
using namespace std;
int n,t,i,j,b,lb[nmax],rb[nmax],rup[nmax],pr[nmax],lst[nmax],nr[nmax],l[nmax],r[nmax],ps[nmax];
void dfs(int x)
{
	if(x<0)return;
	dfs(l[x]);
	if(l[x]==-2 || lb[l[x]])lb[x]=1;
	dfs(r[x]);
	if(r[x]==-2 || lb[r[x]])rb[x]=1;
	if(l[x]>0)rb[x]|=rb[l[x]];
}
void up(int x,int p,int k,int ls)
{
	if(x<0)return;
	nr[x]=k;
	lst[x]=ls;
	pr[x]=p;
	rup[x]=rup[p]|rb[x];
	if(p && r[p]>=0)ps[x]=1;
	ps[x]|=ps[p];
	up(l[x],x,k,ls);
	up(r[x],x,k+1,x);
}
int FindWinner(int T,vector<int> L,vector<int> R)
{
	n=L.size(),t=T;
	for(i=0;i<n;i++)
	{
		l[i+1]=L[i];
		r[i+1]=R[i];
		if(l[i+1]>=0)l[i+1]++;
		if(r[i+1]>=0)r[i+1]++;
	}
	dfs(1);
	up(1,0,0,0);
	for(i=1;i<=n;i++)
	{
		//cout<<i<<" "<<lb[i]<<" "<<rb[i]<<" "<<rup[i]<<" "<<pr[i]<<" "<<lst[i]<<" "<<nr[i]<<endl;
	}
	for(i=1;i<=n;i++)
	{
		if(nr[i]>1)
		{
			if(!rb[1] && !lb[1])return 1;
		}
		else if(nr[i]==1)
		{
			if(r[i]==-2 || lb[r[i]])continue;
			if(lb[1])continue;
			if(rup[pr[lst[i]]])continue;
			if(l[lst[i]]>0 && rb[l[lst[i]]])continue;
			//cout<<i<<endl;
			return 1;
		}
		else
		{
			if(rup[pr[i]])continue;
			if(lb[i])continue;
			if(r[i]!=-2 && rb[r[i]])continue;
			if((r[i]==-2 || lb[r[i]]) && (l[pr[i]]>0 || ps[pr[i]]))continue;
			//cout<<i<<endl;
			return 1;
		}
	}
	return 0;
}

Compilation message

bulb.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
bulb.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 420 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -