Submission #1069904

#TimeUsernameProblemLanguageResultExecution timeMemory
1069904NeroZeinBring Down the Grading Server (CEOI23_gradingserver)C++17
5 / 100
771 ms650576 KiB
#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'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...