Submission #148658

#TimeUsernameProblemLanguageResultExecution timeMemory
148658서울대학교 연구공원 944동 삼성전자서울대연구소 (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
2 ms376 KiB
#include "bulb.h" #include <stdio.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #pragma warning(disable:4996) #pragma comment(linker, "/STACK:336777216") using namespace std; #define mp make_pair #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) ((int)(x).size()) #define rep(i, n) for(int i=0;i<n;i++) #define all(x) (x).begin(), (x).end() #define ldb ldouble typedef tuple<int, int, int> t3; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef pair <ll, int> pli; typedef pair <db, db> pdd; int IT_MAX = 1 << 19; const ll MOD = 1000000007; const int INF = 0x3f3f3f3f; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; const db PI = acos(-1); const db ERR = 1e-10; int son[300050][2]; int dp[300050][3]; int sz[300050]; void DFS(int n) { if (n == 300001 || n == 300002) { dp[n][0] = n - 300001; dp[n][1] = dp[n][2] = 0; sz[n] = 0; return; } DFS(son[n][0]); DFS(son[n][1]); int L = son[n][0], R = son[n][1]; sz[n] = 1; sz[n] += sz[L] + sz[R]; dp[n][0] = dp[L][0]; dp[n][1] = dp[L][1]; dp[n][2] = dp[L][2]; if (dp[R][0] == 0) dp[n][1] = 1; else dp[n][2] = 1; } int FindWinner(int T, std::vector<int> L, std::vector<int> R){ int N = L.size(); for (int i = 0; i < N; i++) { if (L[i] == -1) L[i] = 300001; if (L[i] == -2) L[i] = 300002; if (R[i] == -1) R[i] = 300001; if (R[i] == -2) R[i] = 300002; son[i][0] = L[i], son[i][1] = R[i]; } DFS(0); if (dp[0][0] == 1) return 0; int n = 0; for (int i = 1;; i++) { int L = son[n][0], R = son[n][1]; if (dp[R][0] == 1) { if (i + sz[R] == N && !dp[R][2]) return 1; break; } if (!dp[R][2]) return 1; n = L; if (n >= 300001) break; } int c = 0; for (int n = 0; n <= 300000; n = son[n][0]) { int R = son[n][1]; if (dp[R][0] == 1) c++; } if (c >= 2) return 0; if (c == 1) { for (int n = 0; n <= 300000; n = son[n][0]) { int R = son[n][1]; if (dp[R][0] != 1) continue; if (dp[R][1]) return 1; return 0; } } for (int n = 0; n <= 300000; n = son[n][0]) { int R = son[n][1]; if (dp[R][1]) return 1; } return 0; }

Compilation message (stderr)

bulb.cpp:25:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)  
 
bulb.cpp:26:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:336777216")
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...