이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
while (q--) {
int ch, fh, cg, fg;
cin >> ch >> fh >> cg >> fg;
memset(dp, -1, sizeof dp);
int ok = bt(ch, fh, cg, fg, 0);
cout << (ok ? "YES" : "NO") << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |