Submission #1069903

# Submission time Handle Problem Language Result Execution time Memory
1069903 2024-08-22T09:51:31 Z NeroZein Bring Down the Grading Server (CEOI23_gradingserver) C++17
0 / 100
4000 ms 650604 KB
#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
1 Correct 97 ms 320856 KB Output is correct
2 Runtime error 313 ms 650604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 320848 KB Output is correct
2 Execution timed out 4042 ms 320848 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 320848 KB Output is correct
2 Execution timed out 4042 ms 320848 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 306 ms 650544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 320848 KB Output is correct
2 Execution timed out 4042 ms 320848 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 320848 KB Output is correct
2 Execution timed out 4042 ms 320848 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 320848 KB Output is correct
2 Execution timed out 4042 ms 320848 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 320848 KB Output is correct
2 Execution timed out 4042 ms 320848 KB Time limit exceeded
3 Halted 0 ms 0 KB -