#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int S;
char dp[76][76][76][76];
char dfs(int ch, int fh, int cg, int fg){
if (dp[ch][fh][cg][fg]) return dp[ch][fh][cg][fg];
char &ret = dp[ch][fh][cg][fg];
if (cg==0) return ret = 1;
if (ch==0) return ret = -1;
if (fg == 0) return ret = -dfs(max(cg-ch, 0), fg, ch, fh);
if (ch - fg*S <= 0) return ret = -dfs(cg, max(fg-1, 0), ch, fh);
return ret = -min(dfs(cg, max(fg-1, 0), ch, fh), dfs(max(cg - max(ch - fg*S, 0), 0), fg, ch, fh));
}
int main(){
int q;
scanf("%d %d", &S, &q);
for (int i=0;i<=75;i++) for (int j=0;j<=75;j++) for (int k=0;k<=75;k++) for (int l=0;l<=75;l++) if (!dp[i][j][k][l]){
dfs(i, j, k, l);
}
while(q--){
int x, y, z, w;
scanf("%d %d %d %d", &x, &y, &z, &w);
if (dp[x][y][z][w] > 0) printf("YES\n");
else printf("NO\n");
}
}
Compilation message
gradingserver.cpp: In function 'int main()':
gradingserver.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("%d %d", &S, &q);
| ~~~~~^~~~~~~~~~~~~~~~~
gradingserver.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | scanf("%d %d %d %d", &x, &y, &z, &w);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
227 ms |
33020 KB |
Output is correct |
2 |
Runtime error |
309 ms |
66556 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
32852 KB |
Output is correct |
2 |
Correct |
280 ms |
33924 KB |
Output is correct |
3 |
Correct |
272 ms |
33724 KB |
Output is correct |
4 |
Correct |
276 ms |
33876 KB |
Output is correct |
5 |
Correct |
244 ms |
33760 KB |
Output is correct |
6 |
Correct |
281 ms |
33792 KB |
Output is correct |
7 |
Correct |
291 ms |
33720 KB |
Output is correct |
8 |
Correct |
268 ms |
33876 KB |
Output is correct |
9 |
Correct |
348 ms |
33880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
32852 KB |
Output is correct |
2 |
Correct |
280 ms |
33924 KB |
Output is correct |
3 |
Correct |
272 ms |
33724 KB |
Output is correct |
4 |
Correct |
276 ms |
33876 KB |
Output is correct |
5 |
Correct |
244 ms |
33760 KB |
Output is correct |
6 |
Correct |
281 ms |
33792 KB |
Output is correct |
7 |
Correct |
291 ms |
33720 KB |
Output is correct |
8 |
Correct |
268 ms |
33876 KB |
Output is correct |
9 |
Correct |
348 ms |
33880 KB |
Output is correct |
10 |
Correct |
269 ms |
32816 KB |
Output is correct |
11 |
Correct |
317 ms |
33804 KB |
Output is correct |
12 |
Correct |
302 ms |
33852 KB |
Output is correct |
13 |
Correct |
252 ms |
33872 KB |
Output is correct |
14 |
Correct |
253 ms |
33872 KB |
Output is correct |
15 |
Correct |
298 ms |
33872 KB |
Output is correct |
16 |
Correct |
290 ms |
33872 KB |
Output is correct |
17 |
Correct |
313 ms |
33748 KB |
Output is correct |
18 |
Correct |
391 ms |
33860 KB |
Output is correct |
19 |
Runtime error |
257 ms |
66652 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
306 ms |
66640 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
32852 KB |
Output is correct |
2 |
Correct |
280 ms |
33924 KB |
Output is correct |
3 |
Correct |
272 ms |
33724 KB |
Output is correct |
4 |
Correct |
276 ms |
33876 KB |
Output is correct |
5 |
Correct |
244 ms |
33760 KB |
Output is correct |
6 |
Correct |
281 ms |
33792 KB |
Output is correct |
7 |
Correct |
291 ms |
33720 KB |
Output is correct |
8 |
Correct |
268 ms |
33876 KB |
Output is correct |
9 |
Correct |
348 ms |
33880 KB |
Output is correct |
10 |
Correct |
269 ms |
32816 KB |
Output is correct |
11 |
Correct |
317 ms |
33804 KB |
Output is correct |
12 |
Correct |
302 ms |
33852 KB |
Output is correct |
13 |
Correct |
252 ms |
33872 KB |
Output is correct |
14 |
Correct |
253 ms |
33872 KB |
Output is correct |
15 |
Correct |
298 ms |
33872 KB |
Output is correct |
16 |
Correct |
290 ms |
33872 KB |
Output is correct |
17 |
Correct |
313 ms |
33748 KB |
Output is correct |
18 |
Correct |
391 ms |
33860 KB |
Output is correct |
19 |
Runtime error |
257 ms |
66652 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
32852 KB |
Output is correct |
2 |
Correct |
280 ms |
33924 KB |
Output is correct |
3 |
Correct |
272 ms |
33724 KB |
Output is correct |
4 |
Correct |
276 ms |
33876 KB |
Output is correct |
5 |
Correct |
244 ms |
33760 KB |
Output is correct |
6 |
Correct |
281 ms |
33792 KB |
Output is correct |
7 |
Correct |
291 ms |
33720 KB |
Output is correct |
8 |
Correct |
268 ms |
33876 KB |
Output is correct |
9 |
Correct |
348 ms |
33880 KB |
Output is correct |
10 |
Correct |
269 ms |
32816 KB |
Output is correct |
11 |
Correct |
317 ms |
33804 KB |
Output is correct |
12 |
Correct |
302 ms |
33852 KB |
Output is correct |
13 |
Correct |
252 ms |
33872 KB |
Output is correct |
14 |
Correct |
253 ms |
33872 KB |
Output is correct |
15 |
Correct |
298 ms |
33872 KB |
Output is correct |
16 |
Correct |
290 ms |
33872 KB |
Output is correct |
17 |
Correct |
313 ms |
33748 KB |
Output is correct |
18 |
Correct |
391 ms |
33860 KB |
Output is correct |
19 |
Runtime error |
257 ms |
66652 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
32852 KB |
Output is correct |
2 |
Correct |
280 ms |
33924 KB |
Output is correct |
3 |
Correct |
272 ms |
33724 KB |
Output is correct |
4 |
Correct |
276 ms |
33876 KB |
Output is correct |
5 |
Correct |
244 ms |
33760 KB |
Output is correct |
6 |
Correct |
281 ms |
33792 KB |
Output is correct |
7 |
Correct |
291 ms |
33720 KB |
Output is correct |
8 |
Correct |
268 ms |
33876 KB |
Output is correct |
9 |
Correct |
348 ms |
33880 KB |
Output is correct |
10 |
Correct |
227 ms |
32888 KB |
Output is correct |
11 |
Correct |
279 ms |
33876 KB |
Output is correct |
12 |
Correct |
283 ms |
33768 KB |
Output is correct |
13 |
Correct |
291 ms |
33872 KB |
Output is correct |
14 |
Correct |
280 ms |
33908 KB |
Output is correct |
15 |
Correct |
336 ms |
33888 KB |
Output is correct |
16 |
Correct |
274 ms |
33892 KB |
Output is correct |
17 |
Correct |
266 ms |
33876 KB |
Output is correct |
18 |
Correct |
298 ms |
33944 KB |
Output is correct |
19 |
Runtime error |
232 ms |
66640 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
255 ms |
32852 KB |
Output is correct |
2 |
Correct |
280 ms |
33924 KB |
Output is correct |
3 |
Correct |
272 ms |
33724 KB |
Output is correct |
4 |
Correct |
276 ms |
33876 KB |
Output is correct |
5 |
Correct |
244 ms |
33760 KB |
Output is correct |
6 |
Correct |
281 ms |
33792 KB |
Output is correct |
7 |
Correct |
291 ms |
33720 KB |
Output is correct |
8 |
Correct |
268 ms |
33876 KB |
Output is correct |
9 |
Correct |
348 ms |
33880 KB |
Output is correct |
10 |
Correct |
269 ms |
32816 KB |
Output is correct |
11 |
Correct |
317 ms |
33804 KB |
Output is correct |
12 |
Correct |
302 ms |
33852 KB |
Output is correct |
13 |
Correct |
252 ms |
33872 KB |
Output is correct |
14 |
Correct |
253 ms |
33872 KB |
Output is correct |
15 |
Correct |
298 ms |
33872 KB |
Output is correct |
16 |
Correct |
290 ms |
33872 KB |
Output is correct |
17 |
Correct |
313 ms |
33748 KB |
Output is correct |
18 |
Correct |
391 ms |
33860 KB |
Output is correct |
19 |
Runtime error |
257 ms |
66652 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |