Submission #1056716

# Submission time Handle Problem Language Result Execution time Memory
1056716 2024-08-13T10:43:29 Z rainboy Bring Down the Grading Server (CEOI23_gradingserver) C
65 / 100
307 ms 1048576 KB
#include <stdio.h>
#include <stdlib.h>

#define C	30000
#define R	174	/* R = ceil(sqrt(C)) */
#define INF	0x3f3f3f3f3f3f3f3fLL

long long min(long long a, long long b) { return a < b ? a : b; }
long long max(long long a, long long b) { return a > b ? a : b; }

long long **dpmn[C + 1], **dpmx[C + 1], **dqmn[C + 1], **dqmx[C + 1];
int c;

int solve(long long x1, long long y1, long long x2, long long y2) {
	long long y;
	int w;

	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;
			return y <= y1 && solve(x1 + y * (c - x2), y1 - y, x2, y2);
		} 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 (x2 < c && x1 + y1 * (c - x2) >= c)
		return 1;
	if (x2 >= 0 && x2 < c) {
		if (c - x1 >= 0 && c - x1 <= R) {
			if (y2 < dpmn[x2][y1][c - x1])
				return 1;
			if (y2 > dpmx[x2][y1][c - x1])
				return 0;
		}
		if (y2 <= R) {
			if (x1 < dqmn[x2][y1][y2])
				return 0;
			if (x1 > dqmx[x2][y1][y2])
				return 1;
		}
	}
	if (!solve(x2 - x1, y2, x1, y1)) {
		if (x2 >= 0 && x2 < c) {
			if (c - x1 >= 0 && c - x1 <= R)
				dpmn[x2][y1][c - x1] = max(dpmn[x2][y1][c - x1], y2 + 1);
			if (y2 <= R)
				dqmx[x2][y1][y2] = min(dqmx[x2][y1][y2], x1 - 1);
		}
		return 1;
	}
	if (x2 >= c)
		return 0;
	y = y2 == 0 ? 1 : max(min((x2 + c * (y2 - 1)) / (y2 + 1), x2) - x1, 0) / (c - x2) + 1;
	w = y <= y1 && solve(x1 + y * (c - x2), y1 - y, x2, y2);
	if (x2 >= 0 && x2 < c) {
		if (w) {
			if (c - x1 >= 0 && c - x1 <= R)
				dpmn[x2][y1][c - x1] = max(dpmn[x2][y1][c - x1], y2 + 1);
			if (y2 <= R)
				dqmx[x2][y1][y2] = min(dqmx[x2][y1][y2], x1 - 1);
		} else {
			if (c - x1 >= 0 && c - x1 <= R)
				dpmx[x2][y1][c - x1] = min(dpmx[x2][y1][c - x1], y2 - 1);
			if (y2 <= R)
				dqmn[x2][y1][y2] = max(dqmn[x2][y1][y2], x1 + 1);
		}
	}
	return w;
}

int main() {
	int t, x1, y1, x2, y2;

	scanf("%d%d", &c, &t);
	for (x2 = 0; x2 < c; x2++) {
		dpmn[x2] = (long long **) malloc((c / (c - x2) + 1) * sizeof *dpmn[x2]);
		dpmx[x2] = (long long **) malloc((c / (c - x2) + 1) * sizeof *dpmx[x2]);
		dqmn[x2] = (long long **) malloc((c / (c - x2) + 1) * sizeof *dqmn[x2]);
		dqmx[x2] = (long long **) malloc((c / (c - x2) + 1) * sizeof *dqmx[x2]);
		for (y1 = 0; y1 * (c - x2) <= c; y1++) {
			dpmn[x2][y1] = (long long *) malloc((R + 1) * sizeof *dpmn[x2][y1]);
			dpmx[x2][y1] = (long long *) malloc((R + 1) * sizeof *dpmx[x2][y1]);
			dqmn[x2][y1] = (long long *) malloc((R + 1) * sizeof *dqmn[x2][y1]);
			dqmx[x2][y1] = (long long *) malloc((R + 1) * sizeof *dqmx[x2][y1]);
			for (x1 = 0; x1 <= R; x1++)
				dpmn[x2][y1][x1] = 0, dpmx[x2][y1][x1] = c * 2 + 1;
			for (y2 = 0; y2 <= R; y2++)
				dqmn[x2][y1][y2] = 0, dqmx[x2][y1][y2] = c + 1;
		}
	}
	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:88:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   88 |  scanf("%d%d", &c, &t);
      |  ^~~~~~~~~~~~~~~~~~~~~
gradingserver.c:108:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  108 |   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 600 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 1 ms 600 KB Output is correct
2 Correct 43 ms 1104 KB Output is correct
3 Correct 45 ms 1388 KB Output is correct
4 Correct 44 ms 2384 KB Output is correct
5 Correct 45 ms 3420 KB Output is correct
6 Correct 50 ms 2036 KB Output is correct
7 Correct 45 ms 1720 KB Output is correct
8 Correct 45 ms 1360 KB Output is correct
9 Correct 42 ms 1312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 43 ms 1104 KB Output is correct
3 Correct 45 ms 1388 KB Output is correct
4 Correct 44 ms 2384 KB Output is correct
5 Correct 45 ms 3420 KB Output is correct
6 Correct 50 ms 2036 KB Output is correct
7 Correct 45 ms 1720 KB Output is correct
8 Correct 45 ms 1360 KB Output is correct
9 Correct 42 ms 1312 KB Output is correct
10 Correct 0 ms 856 KB Output is correct
11 Correct 45 ms 1108 KB Output is correct
12 Correct 43 ms 1384 KB Output is correct
13 Correct 45 ms 2384 KB Output is correct
14 Correct 44 ms 3300 KB Output is correct
15 Correct 47 ms 2068 KB Output is correct
16 Correct 45 ms 1732 KB Output is correct
17 Correct 45 ms 1472 KB Output is correct
18 Correct 44 ms 1108 KB Output is correct
19 Correct 49 ms 1108 KB Output is correct
20 Correct 49 ms 1360 KB Output is correct
21 Correct 51 ms 3188 KB Output is correct
22 Correct 57 ms 12644 KB Output is correct
23 Correct 51 ms 12624 KB Output is correct
24 Correct 55 ms 4296 KB Output is correct
25 Correct 56 ms 5972 KB Output is correct
26 Correct 51 ms 1484 KB Output is correct
27 Correct 53 ms 1588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 1192 KB Output is correct
2 Correct 78 ms 1264 KB Output is correct
3 Correct 74 ms 1084 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 43 ms 1104 KB Output is correct
3 Correct 45 ms 1388 KB Output is correct
4 Correct 44 ms 2384 KB Output is correct
5 Correct 45 ms 3420 KB Output is correct
6 Correct 50 ms 2036 KB Output is correct
7 Correct 45 ms 1720 KB Output is correct
8 Correct 45 ms 1360 KB Output is correct
9 Correct 42 ms 1312 KB Output is correct
10 Correct 0 ms 856 KB Output is correct
11 Correct 45 ms 1108 KB Output is correct
12 Correct 43 ms 1384 KB Output is correct
13 Correct 45 ms 2384 KB Output is correct
14 Correct 44 ms 3300 KB Output is correct
15 Correct 47 ms 2068 KB Output is correct
16 Correct 45 ms 1732 KB Output is correct
17 Correct 45 ms 1472 KB Output is correct
18 Correct 44 ms 1108 KB Output is correct
19 Correct 49 ms 1108 KB Output is correct
20 Correct 49 ms 1360 KB Output is correct
21 Correct 51 ms 3188 KB Output is correct
22 Correct 57 ms 12644 KB Output is correct
23 Correct 51 ms 12624 KB Output is correct
24 Correct 55 ms 4296 KB Output is correct
25 Correct 56 ms 5972 KB Output is correct
26 Correct 51 ms 1484 KB Output is correct
27 Correct 53 ms 1588 KB Output is correct
28 Correct 0 ms 604 KB Output is correct
29 Correct 46 ms 1088 KB Output is correct
30 Correct 46 ms 1292 KB Output is correct
31 Correct 49 ms 2452 KB Output is correct
32 Correct 53 ms 3364 KB Output is correct
33 Correct 48 ms 1928 KB Output is correct
34 Correct 52 ms 1620 KB Output is correct
35 Correct 50 ms 1288 KB Output is correct
36 Correct 48 ms 1340 KB Output is correct
37 Correct 54 ms 1108 KB Output is correct
38 Correct 63 ms 1204 KB Output is correct
39 Correct 62 ms 3216 KB Output is correct
40 Correct 54 ms 12492 KB Output is correct
41 Correct 57 ms 12616 KB Output is correct
42 Correct 55 ms 4436 KB Output is correct
43 Correct 58 ms 6124 KB Output is correct
44 Correct 55 ms 1364 KB Output is correct
45 Correct 51 ms 1620 KB Output is correct
46 Correct 70 ms 14512 KB Output is correct
47 Correct 59 ms 1196 KB Output is correct
48 Correct 57 ms 3788 KB Output is correct
49 Correct 91 ms 98352 KB Output is correct
50 Correct 68 ms 48084 KB Output is correct
51 Correct 73 ms 21648 KB Output is correct
52 Correct 99 ms 63320 KB Output is correct
53 Correct 46 ms 2332 KB Output is correct
54 Correct 54 ms 12628 KB Output is correct
55 Correct 60 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 43 ms 1104 KB Output is correct
3 Correct 45 ms 1388 KB Output is correct
4 Correct 44 ms 2384 KB Output is correct
5 Correct 45 ms 3420 KB Output is correct
6 Correct 50 ms 2036 KB Output is correct
7 Correct 45 ms 1720 KB Output is correct
8 Correct 45 ms 1360 KB Output is correct
9 Correct 42 ms 1312 KB Output is correct
10 Correct 0 ms 856 KB Output is correct
11 Correct 45 ms 1108 KB Output is correct
12 Correct 43 ms 1384 KB Output is correct
13 Correct 45 ms 2384 KB Output is correct
14 Correct 44 ms 3300 KB Output is correct
15 Correct 47 ms 2068 KB Output is correct
16 Correct 45 ms 1732 KB Output is correct
17 Correct 45 ms 1472 KB Output is correct
18 Correct 44 ms 1108 KB Output is correct
19 Correct 49 ms 1108 KB Output is correct
20 Correct 49 ms 1360 KB Output is correct
21 Correct 51 ms 3188 KB Output is correct
22 Correct 57 ms 12644 KB Output is correct
23 Correct 51 ms 12624 KB Output is correct
24 Correct 55 ms 4296 KB Output is correct
25 Correct 56 ms 5972 KB Output is correct
26 Correct 51 ms 1484 KB Output is correct
27 Correct 53 ms 1588 KB Output is correct
28 Correct 73 ms 1192 KB Output is correct
29 Correct 78 ms 1264 KB Output is correct
30 Correct 74 ms 1084 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 74 ms 1108 KB Output is correct
33 Correct 80 ms 1244 KB Output is correct
34 Correct 95 ms 1296 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 604 KB Output is correct
37 Correct 51 ms 1204 KB Output is correct
38 Correct 45 ms 1340 KB Output is correct
39 Correct 51 ms 2388 KB Output is correct
40 Correct 52 ms 3480 KB Output is correct
41 Correct 45 ms 2112 KB Output is correct
42 Correct 45 ms 1720 KB Output is correct
43 Correct 47 ms 1364 KB Output is correct
44 Correct 46 ms 1140 KB Output is correct
45 Correct 59 ms 1104 KB Output is correct
46 Correct 77 ms 1264 KB Output is correct
47 Correct 50 ms 3412 KB Output is correct
48 Correct 54 ms 12628 KB Output is correct
49 Correct 51 ms 12716 KB Output is correct
50 Correct 54 ms 4428 KB Output is correct
51 Correct 57 ms 6044 KB Output is correct
52 Correct 48 ms 1476 KB Output is correct
53 Correct 47 ms 1620 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 77 ms 2404 KB Output is correct
56 Correct 81 ms 12628 KB Output is correct
57 Correct 95 ms 14516 KB Output is correct
58 Correct 62 ms 1352 KB Output is correct
59 Correct 58 ms 3756 KB Output is correct
60 Correct 86 ms 16916 KB Output is correct
61 Correct 86 ms 17028 KB Output is correct
62 Correct 85 ms 8108 KB Output is correct
63 Correct 78 ms 2812 KB Output is correct
64 Correct 82 ms 2024 KB Output is correct
65 Correct 73 ms 1344 KB Output is correct
66 Correct 53 ms 17180 KB Output is correct
67 Correct 51 ms 16976 KB Output is correct
68 Correct 71 ms 2388 KB Output is correct
69 Correct 74 ms 5956 KB Output is correct
70 Correct 93 ms 12624 KB Output is correct
71 Correct 103 ms 16932 KB Output is correct
72 Correct 76 ms 12620 KB Output is correct
73 Correct 58 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 43 ms 1104 KB Output is correct
3 Correct 45 ms 1388 KB Output is correct
4 Correct 44 ms 2384 KB Output is correct
5 Correct 45 ms 3420 KB Output is correct
6 Correct 50 ms 2036 KB Output is correct
7 Correct 45 ms 1720 KB Output is correct
8 Correct 45 ms 1360 KB Output is correct
9 Correct 42 ms 1312 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 47 ms 1248 KB Output is correct
12 Correct 43 ms 1384 KB Output is correct
13 Correct 44 ms 2292 KB Output is correct
14 Correct 45 ms 3408 KB Output is correct
15 Correct 45 ms 2128 KB Output is correct
16 Correct 45 ms 1620 KB Output is correct
17 Correct 45 ms 1360 KB Output is correct
18 Correct 43 ms 1116 KB Output is correct
19 Correct 57 ms 2348 KB Output is correct
20 Correct 178 ms 252572 KB Output is correct
21 Runtime error 307 ms 1048576 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 43 ms 1104 KB Output is correct
3 Correct 45 ms 1388 KB Output is correct
4 Correct 44 ms 2384 KB Output is correct
5 Correct 45 ms 3420 KB Output is correct
6 Correct 50 ms 2036 KB Output is correct
7 Correct 45 ms 1720 KB Output is correct
8 Correct 45 ms 1360 KB Output is correct
9 Correct 42 ms 1312 KB Output is correct
10 Correct 0 ms 856 KB Output is correct
11 Correct 45 ms 1108 KB Output is correct
12 Correct 43 ms 1384 KB Output is correct
13 Correct 45 ms 2384 KB Output is correct
14 Correct 44 ms 3300 KB Output is correct
15 Correct 47 ms 2068 KB Output is correct
16 Correct 45 ms 1732 KB Output is correct
17 Correct 45 ms 1472 KB Output is correct
18 Correct 44 ms 1108 KB Output is correct
19 Correct 49 ms 1108 KB Output is correct
20 Correct 49 ms 1360 KB Output is correct
21 Correct 51 ms 3188 KB Output is correct
22 Correct 57 ms 12644 KB Output is correct
23 Correct 51 ms 12624 KB Output is correct
24 Correct 55 ms 4296 KB Output is correct
25 Correct 56 ms 5972 KB Output is correct
26 Correct 51 ms 1484 KB Output is correct
27 Correct 53 ms 1588 KB Output is correct
28 Correct 73 ms 1192 KB Output is correct
29 Correct 78 ms 1264 KB Output is correct
30 Correct 74 ms 1084 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 604 KB Output is correct
33 Correct 46 ms 1088 KB Output is correct
34 Correct 46 ms 1292 KB Output is correct
35 Correct 49 ms 2452 KB Output is correct
36 Correct 53 ms 3364 KB Output is correct
37 Correct 48 ms 1928 KB Output is correct
38 Correct 52 ms 1620 KB Output is correct
39 Correct 50 ms 1288 KB Output is correct
40 Correct 48 ms 1340 KB Output is correct
41 Correct 54 ms 1108 KB Output is correct
42 Correct 63 ms 1204 KB Output is correct
43 Correct 62 ms 3216 KB Output is correct
44 Correct 54 ms 12492 KB Output is correct
45 Correct 57 ms 12616 KB Output is correct
46 Correct 55 ms 4436 KB Output is correct
47 Correct 58 ms 6124 KB Output is correct
48 Correct 55 ms 1364 KB Output is correct
49 Correct 51 ms 1620 KB Output is correct
50 Correct 70 ms 14512 KB Output is correct
51 Correct 59 ms 1196 KB Output is correct
52 Correct 57 ms 3788 KB Output is correct
53 Correct 91 ms 98352 KB Output is correct
54 Correct 68 ms 48084 KB Output is correct
55 Correct 73 ms 21648 KB Output is correct
56 Correct 99 ms 63320 KB Output is correct
57 Correct 46 ms 2332 KB Output is correct
58 Correct 54 ms 12628 KB Output is correct
59 Correct 60 ms 3404 KB Output is correct
60 Correct 74 ms 1108 KB Output is correct
61 Correct 80 ms 1244 KB Output is correct
62 Correct 95 ms 1296 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 604 KB Output is correct
65 Correct 51 ms 1204 KB Output is correct
66 Correct 45 ms 1340 KB Output is correct
67 Correct 51 ms 2388 KB Output is correct
68 Correct 52 ms 3480 KB Output is correct
69 Correct 45 ms 2112 KB Output is correct
70 Correct 45 ms 1720 KB Output is correct
71 Correct 47 ms 1364 KB Output is correct
72 Correct 46 ms 1140 KB Output is correct
73 Correct 59 ms 1104 KB Output is correct
74 Correct 77 ms 1264 KB Output is correct
75 Correct 50 ms 3412 KB Output is correct
76 Correct 54 ms 12628 KB Output is correct
77 Correct 51 ms 12716 KB Output is correct
78 Correct 54 ms 4428 KB Output is correct
79 Correct 57 ms 6044 KB Output is correct
80 Correct 48 ms 1476 KB Output is correct
81 Correct 47 ms 1620 KB Output is correct
82 Correct 0 ms 344 KB Output is correct
83 Correct 77 ms 2404 KB Output is correct
84 Correct 81 ms 12628 KB Output is correct
85 Correct 95 ms 14516 KB Output is correct
86 Correct 62 ms 1352 KB Output is correct
87 Correct 58 ms 3756 KB Output is correct
88 Correct 86 ms 16916 KB Output is correct
89 Correct 86 ms 17028 KB Output is correct
90 Correct 85 ms 8108 KB Output is correct
91 Correct 78 ms 2812 KB Output is correct
92 Correct 82 ms 2024 KB Output is correct
93 Correct 73 ms 1344 KB Output is correct
94 Correct 53 ms 17180 KB Output is correct
95 Correct 51 ms 16976 KB Output is correct
96 Correct 71 ms 2388 KB Output is correct
97 Correct 74 ms 5956 KB Output is correct
98 Correct 93 ms 12624 KB Output is correct
99 Correct 103 ms 16932 KB Output is correct
100 Correct 76 ms 12620 KB Output is correct
101 Correct 58 ms 16732 KB Output is correct
102 Correct 0 ms 604 KB Output is correct
103 Correct 47 ms 1248 KB Output is correct
104 Correct 43 ms 1384 KB Output is correct
105 Correct 44 ms 2292 KB Output is correct
106 Correct 45 ms 3408 KB Output is correct
107 Correct 45 ms 2128 KB Output is correct
108 Correct 45 ms 1620 KB Output is correct
109 Correct 45 ms 1360 KB Output is correct
110 Correct 43 ms 1116 KB Output is correct
111 Correct 57 ms 2348 KB Output is correct
112 Correct 178 ms 252572 KB Output is correct
113 Runtime error 307 ms 1048576 KB Execution killed with signal 9
114 Halted 0 ms 0 KB -