Submission #150560

#TimeUsernameProblemLanguageResultExecution timeMemory
150560Greedy left the chat. (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms504 KiB
#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 (stderr)

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")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...