# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
150539 | | 준표야 함수컵은 캐리해줄거지? (#200) | Bulb Game (FXCUP4_bulb) | C++17 | | 6 ms | 4984 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
return cur==-1;
}
int &ret = dp[MAXN][f][t%2];
if(ret!=-1) return ret;
ret = 0;
if(!f) {
ret |= max(dfs(L[cur], !f, t, L, R),
dfs(L[cur], f, (t+1)%2, L, R)
);
}
else {
ret |= max(dfs(L[cur], !f, (t+1)%2, L, R),
dfs(L[cur], f, (t+2)%2, L, R)
);
}
if(!f) {
ret |= max(dfs(R[cur], !f, (t+1)%2, L, R),
dfs(R[cur], f, (t+2)%2, L, R)
);
}
else {
ret |= max(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;
}
Compilation message (stderr)
bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:46: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:16:20: warning: array subscript is above array bounds [-Warray-bounds]
int &ret = dp[MAXN][f][t%2];
~~~~~~~^
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:16:20: warning: array subscript is above array bounds [-Warray-bounds]
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |