제출 #150811

#제출 시각아이디문제언어결과실행 시간메모리
150811준표야 함수컵은 캐리해줄거지? (#200)Bulb Game (FXCUP4_bulb)C++17
0 / 100
6 ms5032 KiB
#include "bulb.h" #include <vector> #include <string.h> #include <algorithm> using namespace std; const int MAXN = 300003; int dp[MAXN][2][2]; int dfs(int cur, int f, int t, vector<int> &L, vector<int> &R) { if(cur<0) { if(t==0) return cur==-1; return 0; } int &ret = dp[MAXN][f][t]; if(ret!=-1) return ret; ret = 0; if(!f) { if(t) { ret |= max(dfs(L[cur], !f, t, L, R), dfs(L[cur], f, (t+1)%2, L, R) ); } else { ret |= min(dfs(L[cur], !f, t, L, R), dfs(L[cur], f, (t+1)%2, L, R) ); } } else { if(t) { ret |= max(dfs(L[cur], !f, (t+1)%2, L, R), dfs(L[cur], f, (t+2)%2, L, R) ); } else { ret |= min(dfs(L[cur], !f, (t+1)%2, L, R), dfs(L[cur], f, (t+2)%2, L, R) ); } } if(!f) { if(t) { ret |= max(dfs(R[cur], !f, (t+1)%2, L, R), dfs(R[cur], f, (t+2)%2, L, R) ); } else { ret |= min(dfs(R[cur], !f, (t+1)%2, L, R), dfs(R[cur], f, (t+2)%2, L, R) ); } } else { if(t) { ret |= max(dfs(R[cur], !f, t, L, R), dfs(R[cur], f, (t+1)%2, L, R) ); } else { ret |= min(dfs(R[cur], !f, t, L, R), dfs(R[cur], f, (t+1)%2, L, R) ); } } return ret; } int FindWinner(int T, vector<int> L, vector<int> R){ int N = L.size(); memset(dp, -1, sizeof(dp)); T%=2; int ans = dfs(0, 0, T, L, R); return ans==1; }

컴파일 시 표준 에러 (stderr) 메시지

bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:77:6: warning: unused variable 'N' [-Wunused-variable]
  int N = L.size();
      ^
bulb.cpp: In function 'int dfs(int, int, int, std::vector<int>&, std::vector<int>&)':
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
  int &ret = dp[MAXN][f][t];
             ~~~~~~~^
bulb.cpp: In function 'int dfs(int, int, int, std::vector<int>&, std::vector<int>&)':
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:17:20: warning: array subscript is above array bounds [-Warray-bounds]
  int &ret = dp[MAXN][f][t];
             ~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...