Submission #150127

#TimeUsernameProblemLanguageResultExecution timeMemory
150127TLEWA맞 (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms376 KiB
#include "bulb.h" #include <bits/stdc++.h> #define F first #define S second #define pb push_back using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; int dp[300010]; //(r, r)=1, (r, b)=2, (b, r)=3, (b, b)=4; int n; int winnable=-1; vector<int> l, r; void get_dp(int num) { if(l[num]==-1&&r[num]==-1)dp[num]=1; if(l[num]==-1&&r[num]==-2)dp[num]=2; if(l[num]==-2&&r[num]==-1)dp[num]=3; if(l[num]==-2&&r[num]==-2)dp[num]=4; if(l[num]<0&&r[num]>=0){ get_dp(r[num]); if(dp[r[num]]<=2&&l[num]==-1)dp[num]=1; if(dp[r[num]]<=2&&l[num]==-2)dp[num]=3; if(dp[r[num]]>=3&&l[num]==-1)dp[num]=2; if(dp[r[num]]>=3&&l[num]==-2)dp[num]=4; } if(r[num]<0&&l[num]>=0){ get_dp(l[num]); if(dp[l[num]]<=2&&r[num]==-1)dp[num]=1; if(dp[l[num]]<=2&&r[num]==-2)dp[num]=2; if(dp[l[num]]>=3&&r[num]==-1)dp[num]=3; if(dp[l[num]]>=3&&r[num]==-2)dp[num]=4; } if(l[num]>=0&r[num]>=0){ get_dp(r[num]); get_dp(l[num]); if(dp[l[num]]<=2&&dp[r[num]]<=2)dp[num]=1; if(dp[l[num]]<=2&&dp[r[num]]>=3)dp[num]=2; if(dp[l[num]]>=3&&dp[r[num]]<=2)dp[num]=3; if(dp[l[num]]>=3&&dp[r[num]]>=3)dp[num]=4; } } void dfs(int num) { if(l[num]<0)return; if(dp[num]!=1){ winnable=0; return; } if(r[num]>=0){ if(dp[r[num]]==1){ winnable=1; return; } } dfs(l[num]); } int FindWinner(int t, std::vector<int> L, std::vector<int> R){ l=L; r=R; n = l.size(); get_dp(0); dfs(0); return winnable==1; }

Compilation message (stderr)

bulb.cpp: In function 'void get_dp(int)':
bulb.cpp:34:14: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
     if(l[num]>=0&r[num]>=0){
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...