#include "bulb.h"
#include <vector>
#include <string.h>
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];
if(ret!=-1) return ret;
ret = 0;
if(!f) {
ret |= max(dfs(L[cur], !f, t, L, R), dfs(L[cur], f, t, L, R));
}
else {
ret |= max(dfs(L[cur], !f, (t+1)%2, L, R), dfs(L[cur], f, (t+1)%2, L, R));
}
if(!f) {
ret |= max(dfs(R[cur], !f, (t+1)%2, L, R), dfs(R[cur], f, (t+1)%2, L, R));
}
else {
ret |= max(dfs(R[cur], !f, t, L, R), dfs(R[cur], f, t, L, R));
}
return ret;
}
int FindWinner(int T, vector<int> L, vector<int> R){
int N = L.size();
memset(dp, -1, sizeof(dp));
int ans = dfs(0, 0, T%2, L, R);
if(ans%2 == T%2) return 0;
return 1;
}
Compilation message
bulb.cpp: In function 'int FindWinner(int, std::vector<int>, std::vector<int>)':
bulb.cpp:37: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:15: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:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15:20: warning: array subscript is above array bounds [-Warray-bounds]
bulb.cpp:15: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:15:20: warning: array subscript is above array bounds [-Warray-bounds]
int &ret = dp[MAXN][f][t];
~~~~~~~^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
5044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
4984 KB |
Output is correct |
3 |
Incorrect |
6 ms |
5044 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4984 KB |
Output is correct |
2 |
Correct |
6 ms |
4984 KB |
Output is correct |
3 |
Incorrect |
6 ms |
5044 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |