#include <bits/stdc++.h>
using namespace std;
int dp[309][309][309], s;
void go(int fh, int cg, int fg);
bool win(int ch, int fh, int cg, int fg){
if(ch<=0)
return 0;
go(fh, cg, fg);
return ch >= dp[fh][cg][fg];
}
void go(int fh, int cg, int fg){
//printf("fh=%d cg=%d fg=%d\n", fh, cg, fg);
if(dp[fh][cg][fg] != -1)
return;
if(cg == 0)
dp[fh][cg][fg] = 0;
else{
int lo = 1, hi = 301;
while(lo < hi){
int ch = lo;
if(fg > 0 && !win(cg, max(fg-1, 0), ch, fh)){
hi = ch; break;
}
else if(ch-fg*s > 0 && !win(max(cg-max(ch-fg*s, 0), 0),fg, ch, fh)){
hi = ch;
break;
}
else
lo = ch+1;
}
dp[fh][cg][fg] = lo==301 ? 1000000009 : lo;
}
}
int main(){
int q, ch, fh, cg, fg, i;
scanf("%d %d", &s, &q);
memset(dp, -1, sizeof(dp));
while(q--){
scanf("%d %d %d %d", &ch, &fh, &cg, &fg);
printf("%s\n", win(ch,fh,cg,fg) ? "YES" : "NO");
}
return 0;
}
Compilation message
gradingserver.cpp: In function 'int main()':
gradingserver.cpp:35:25: warning: unused variable 'i' [-Wunused-variable]
35 | int q, ch, fh, cg, fg, i;
| ^
gradingserver.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%d %d", &s, &q);
| ~~~~~^~~~~~~~~~~~~~~~~
gradingserver.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | scanf("%d %d %d %d", &ch, &fh, &cg, &fg);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
115796 KB |
Output is correct |
2 |
Incorrect |
28 ms |
115804 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
115804 KB |
Output is correct |
2 |
Runtime error |
478 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
115804 KB |
Output is correct |
2 |
Runtime error |
478 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
107 ms |
234428 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
115804 KB |
Output is correct |
2 |
Runtime error |
478 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
115804 KB |
Output is correct |
2 |
Runtime error |
478 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
115804 KB |
Output is correct |
2 |
Runtime error |
478 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
115804 KB |
Output is correct |
2 |
Runtime error |
478 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |