#include <bits/stdc++.h>
using namespace std;
const int N = 80;
int s, q;
int dp[N][N][N][N][2];
int bt(int ch, int fh, int cg, int fg, bool turn) {
if (turn == 0) {
if (ch < 0) {
return false;
}
int& ret = dp[ch][fh][cg][fg][turn];
if (ret != -1) {
return ret;
}
ret = 0;
if (fg) {
ret |= bt(ch, fh, cg, fg - 1, turn ^ 1) == 0;
}
int damage = ch - fg * s;
if (damage > 0) {
ret |= bt(ch, fh, cg - damage, fg, turn ^ 1) == 0;
}
return ret;
} else {
if (cg < 0) {
return false;
}
int& ret = dp[ch][fh][cg][fg][turn];
if (ret != -1) {
return ret;
}
ret = 0;
if (fh) {
ret |= bt(ch, fh - 1, cg, fg, turn ^ 1) == 0;
}
int damage = cg - fh * s;
if (damage > 0) {
ret |= bt(ch - damage, fh, cg, fg, turn ^ 1) == 0;
}
return ret;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> s >> q;
memset(dp, -1, sizeof dp);
while (q--) {
int ch, fh, cg, fg;
cin >> ch >> fh >> cg >> fg;
int ok = bt(ch, fh, cg, fg, 0);
cout << (ok ? "YES" : "NO") << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
80 ms |
320848 KB |
Output is correct |
2 |
Runtime error |
308 ms |
650540 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
320852 KB |
Output is correct |
2 |
Correct |
633 ms |
324508 KB |
Output is correct |
3 |
Correct |
456 ms |
324776 KB |
Output is correct |
4 |
Correct |
310 ms |
324692 KB |
Output is correct |
5 |
Correct |
416 ms |
324720 KB |
Output is correct |
6 |
Correct |
206 ms |
324692 KB |
Output is correct |
7 |
Correct |
217 ms |
324612 KB |
Output is correct |
8 |
Correct |
240 ms |
324692 KB |
Output is correct |
9 |
Correct |
627 ms |
324616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
320852 KB |
Output is correct |
2 |
Correct |
633 ms |
324508 KB |
Output is correct |
3 |
Correct |
456 ms |
324776 KB |
Output is correct |
4 |
Correct |
310 ms |
324692 KB |
Output is correct |
5 |
Correct |
416 ms |
324720 KB |
Output is correct |
6 |
Correct |
206 ms |
324692 KB |
Output is correct |
7 |
Correct |
217 ms |
324612 KB |
Output is correct |
8 |
Correct |
240 ms |
324692 KB |
Output is correct |
9 |
Correct |
627 ms |
324616 KB |
Output is correct |
10 |
Correct |
88 ms |
320848 KB |
Output is correct |
11 |
Correct |
665 ms |
324692 KB |
Output is correct |
12 |
Correct |
483 ms |
324692 KB |
Output is correct |
13 |
Correct |
313 ms |
324692 KB |
Output is correct |
14 |
Correct |
362 ms |
324528 KB |
Output is correct |
15 |
Correct |
232 ms |
324524 KB |
Output is correct |
16 |
Correct |
223 ms |
324472 KB |
Output is correct |
17 |
Correct |
263 ms |
324692 KB |
Output is correct |
18 |
Correct |
603 ms |
324672 KB |
Output is correct |
19 |
Runtime error |
367 ms |
650576 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
311 ms |
650576 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
320852 KB |
Output is correct |
2 |
Correct |
633 ms |
324508 KB |
Output is correct |
3 |
Correct |
456 ms |
324776 KB |
Output is correct |
4 |
Correct |
310 ms |
324692 KB |
Output is correct |
5 |
Correct |
416 ms |
324720 KB |
Output is correct |
6 |
Correct |
206 ms |
324692 KB |
Output is correct |
7 |
Correct |
217 ms |
324612 KB |
Output is correct |
8 |
Correct |
240 ms |
324692 KB |
Output is correct |
9 |
Correct |
627 ms |
324616 KB |
Output is correct |
10 |
Correct |
88 ms |
320848 KB |
Output is correct |
11 |
Correct |
665 ms |
324692 KB |
Output is correct |
12 |
Correct |
483 ms |
324692 KB |
Output is correct |
13 |
Correct |
313 ms |
324692 KB |
Output is correct |
14 |
Correct |
362 ms |
324528 KB |
Output is correct |
15 |
Correct |
232 ms |
324524 KB |
Output is correct |
16 |
Correct |
223 ms |
324472 KB |
Output is correct |
17 |
Correct |
263 ms |
324692 KB |
Output is correct |
18 |
Correct |
603 ms |
324672 KB |
Output is correct |
19 |
Runtime error |
367 ms |
650576 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
320852 KB |
Output is correct |
2 |
Correct |
633 ms |
324508 KB |
Output is correct |
3 |
Correct |
456 ms |
324776 KB |
Output is correct |
4 |
Correct |
310 ms |
324692 KB |
Output is correct |
5 |
Correct |
416 ms |
324720 KB |
Output is correct |
6 |
Correct |
206 ms |
324692 KB |
Output is correct |
7 |
Correct |
217 ms |
324612 KB |
Output is correct |
8 |
Correct |
240 ms |
324692 KB |
Output is correct |
9 |
Correct |
627 ms |
324616 KB |
Output is correct |
10 |
Correct |
88 ms |
320848 KB |
Output is correct |
11 |
Correct |
665 ms |
324692 KB |
Output is correct |
12 |
Correct |
483 ms |
324692 KB |
Output is correct |
13 |
Correct |
313 ms |
324692 KB |
Output is correct |
14 |
Correct |
362 ms |
324528 KB |
Output is correct |
15 |
Correct |
232 ms |
324524 KB |
Output is correct |
16 |
Correct |
223 ms |
324472 KB |
Output is correct |
17 |
Correct |
263 ms |
324692 KB |
Output is correct |
18 |
Correct |
603 ms |
324672 KB |
Output is correct |
19 |
Runtime error |
367 ms |
650576 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
320852 KB |
Output is correct |
2 |
Correct |
633 ms |
324508 KB |
Output is correct |
3 |
Correct |
456 ms |
324776 KB |
Output is correct |
4 |
Correct |
310 ms |
324692 KB |
Output is correct |
5 |
Correct |
416 ms |
324720 KB |
Output is correct |
6 |
Correct |
206 ms |
324692 KB |
Output is correct |
7 |
Correct |
217 ms |
324612 KB |
Output is correct |
8 |
Correct |
240 ms |
324692 KB |
Output is correct |
9 |
Correct |
627 ms |
324616 KB |
Output is correct |
10 |
Correct |
87 ms |
320916 KB |
Output is correct |
11 |
Correct |
771 ms |
324688 KB |
Output is correct |
12 |
Correct |
488 ms |
324644 KB |
Output is correct |
13 |
Correct |
302 ms |
324692 KB |
Output is correct |
14 |
Correct |
377 ms |
324740 KB |
Output is correct |
15 |
Correct |
186 ms |
324680 KB |
Output is correct |
16 |
Correct |
209 ms |
324688 KB |
Output is correct |
17 |
Correct |
258 ms |
324688 KB |
Output is correct |
18 |
Correct |
636 ms |
324688 KB |
Output is correct |
19 |
Runtime error |
302 ms |
650576 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
320852 KB |
Output is correct |
2 |
Correct |
633 ms |
324508 KB |
Output is correct |
3 |
Correct |
456 ms |
324776 KB |
Output is correct |
4 |
Correct |
310 ms |
324692 KB |
Output is correct |
5 |
Correct |
416 ms |
324720 KB |
Output is correct |
6 |
Correct |
206 ms |
324692 KB |
Output is correct |
7 |
Correct |
217 ms |
324612 KB |
Output is correct |
8 |
Correct |
240 ms |
324692 KB |
Output is correct |
9 |
Correct |
627 ms |
324616 KB |
Output is correct |
10 |
Correct |
88 ms |
320848 KB |
Output is correct |
11 |
Correct |
665 ms |
324692 KB |
Output is correct |
12 |
Correct |
483 ms |
324692 KB |
Output is correct |
13 |
Correct |
313 ms |
324692 KB |
Output is correct |
14 |
Correct |
362 ms |
324528 KB |
Output is correct |
15 |
Correct |
232 ms |
324524 KB |
Output is correct |
16 |
Correct |
223 ms |
324472 KB |
Output is correct |
17 |
Correct |
263 ms |
324692 KB |
Output is correct |
18 |
Correct |
603 ms |
324672 KB |
Output is correct |
19 |
Runtime error |
367 ms |
650576 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |