Submission #1049435

# Submission time Handle Problem Language Result Execution time Memory
1049435 2024-08-08T18:26:28 Z rainboy Bring Down the Grading Server (CEOI23_gradingserver) C
10 / 100
125 ms 1156 KB
#include <stdio.h>
 
long long min(long long a, long long b) { return a < b ? a : b; }
 
int c;
 
int solve(long long x1, long long y1, long long x2, long long y2) {
	long long y;
 
	if (x1 + y1 * c <= 0)
		return 0;
	if (x2 + y2 * c <= 0)
		return 1;
	if (x1 <= 0) {
		if (x2 > 0) {
			if (x2 >= c)
				return 0;
			if (y2 > 0) {
				if (x2 - x1 >= c)
					return 0;
				return !solve(x2, y2, x1 + c, y1 - 1);
			}
			y = -x1 / (c - x2) + 1;
			if (y > y1)
				return 0;
			return !solve(x2, y2, x1 + y * c, y1 - y);
		} else {
			y = min(-x1 / c + 1, -x2 / c + 1);
			return solve(x1 + y * c, y1 - y, x2 + y * c, y2 - y);
		}
	}
	if (x1 >= x2 && (x1 >= c || y1 > 0))
		return 1;
	if (!solve(x2 - x1, y2, x1, y1))
		return 1;
	if (x2 >= c || y1 == 0)
		return 0;
	return !solve(x2, y2, x1 + c, y1 - 1);
}
 
int main() {
	int t;
 
	scanf("%d%d", &c, &t);
	while (t--) {
		long long x1, y1, x2, y2;
 
		scanf("%lld%lld%lld%lld", &x1, &y2, &x2, &y1), x1 -= y1 * c, x2 -= y2 * c;
		printf(solve(x1, y1, x2, y2) ? "YES\n" : "NO\n");
	}
	return 0;
}

Compilation message

gradingserver.c: In function 'main':
gradingserver.c:44:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |  scanf("%d%d", &c, &t);
      |  ^~~~~~~~~~~~~~~~~~~~~
gradingserver.c:48:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   scanf("%lld%lld%lld%lld", &x1, &y2, &x2, &y1), x1 -= y1 * c, x2 -= y2 * c;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 1120 KB Output is correct
3 Incorrect 48 ms 1088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 1120 KB Output is correct
3 Incorrect 48 ms 1088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1108 KB Output is correct
2 Correct 125 ms 1156 KB Output is correct
3 Correct 72 ms 1108 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 1120 KB Output is correct
3 Incorrect 48 ms 1088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 1120 KB Output is correct
3 Incorrect 48 ms 1088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 1120 KB Output is correct
3 Incorrect 48 ms 1088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 50 ms 1120 KB Output is correct
3 Incorrect 48 ms 1088 KB Output isn't correct
4 Halted 0 ms 0 KB -