답안 #1056687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056687 2024-08-13T10:37:24 Z rainboy Bring Down the Grading Server (CEOI23_gradingserver) C
65 / 100
4000 ms 991456 KB
#include <stdio.h>
#include <stdlib.h>

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

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; }

int **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] = (int **) malloc((c / (c - x2) + 1) * sizeof *dpmn[x2]);
		dpmx[x2] = (int **) malloc((c / (c - x2) + 1) * sizeof *dpmx[x2]);
		dqmn[x2] = (int **) malloc((c / (c - x2) + 1) * sizeof *dqmn[x2]);
		dqmx[x2] = (int **) malloc((c / (c - x2) + 1) * sizeof *dqmx[x2]);
		for (y1 = 0; y1 * (c - x2) <= c; y1++) {
			dpmn[x2][y1] = (int *) malloc((R + 1) * sizeof *dpmn[x2][y1]);
			dpmx[x2][y1] = (int *) malloc((R + 1) * sizeof *dpmx[x2][y1]);
			dqmn[x2][y1] = (int *) malloc((R + 1) * sizeof *dqmn[x2][y1]);
			dqmx[x2][y1] = (int *) malloc((R + 1) * sizeof *dqmx[x2][y1]);
			for (x1 = 0; x1 <= R; x1++)
				dpmn[x2][y1][x1] = 0, dpmx[x2][y1][x1] = c;
			for (y2 = 0; y2 <= R; y2++)
				dqmn[x2][y1][y2] = 0, dqmx[x2][y1][y2] = c;
		}
	}
	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:89:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |  scanf("%d%d", &c, &t);
      |  ^~~~~~~~~~~~~~~~~~~~~
gradingserver.c:109:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  109 |   scanf("%lld%lld%lld%lld", &x1, &y2, &x2, &y1), x1 -= y1 * c, x2 -= y2 * c;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 47 ms 1088 KB Output is correct
3 Correct 49 ms 1304 KB Output is correct
4 Correct 47 ms 4692 KB Output is correct
5 Correct 57 ms 5164 KB Output is correct
6 Correct 54 ms 4372 KB Output is correct
7 Correct 56 ms 4228 KB Output is correct
8 Correct 55 ms 4068 KB Output is correct
9 Correct 44 ms 3940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 47 ms 1088 KB Output is correct
3 Correct 49 ms 1304 KB Output is correct
4 Correct 47 ms 4692 KB Output is correct
5 Correct 57 ms 5164 KB Output is correct
6 Correct 54 ms 4372 KB Output is correct
7 Correct 56 ms 4228 KB Output is correct
8 Correct 55 ms 4068 KB Output is correct
9 Correct 44 ms 3940 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 46 ms 4040 KB Output is correct
12 Correct 43 ms 4180 KB Output is correct
13 Correct 47 ms 4504 KB Output is correct
14 Correct 45 ms 5160 KB Output is correct
15 Correct 90 ms 4344 KB Output is correct
16 Correct 53 ms 4176 KB Output is correct
17 Correct 44 ms 4016 KB Output is correct
18 Correct 41 ms 3952 KB Output is correct
19 Correct 51 ms 4688 KB Output is correct
20 Correct 51 ms 4432 KB Output is correct
21 Correct 80 ms 5972 KB Output is correct
22 Correct 51 ms 10644 KB Output is correct
23 Correct 55 ms 10776 KB Output is correct
24 Correct 49 ms 5972 KB Output is correct
25 Correct 64 ms 7060 KB Output is correct
26 Correct 44 ms 4700 KB Output is correct
27 Correct 50 ms 4776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 1104 KB Output is correct
2 Correct 68 ms 1108 KB Output is correct
3 Correct 107 ms 1252 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 47 ms 1088 KB Output is correct
3 Correct 49 ms 1304 KB Output is correct
4 Correct 47 ms 4692 KB Output is correct
5 Correct 57 ms 5164 KB Output is correct
6 Correct 54 ms 4372 KB Output is correct
7 Correct 56 ms 4228 KB Output is correct
8 Correct 55 ms 4068 KB Output is correct
9 Correct 44 ms 3940 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 46 ms 4040 KB Output is correct
12 Correct 43 ms 4180 KB Output is correct
13 Correct 47 ms 4504 KB Output is correct
14 Correct 45 ms 5160 KB Output is correct
15 Correct 90 ms 4344 KB Output is correct
16 Correct 53 ms 4176 KB Output is correct
17 Correct 44 ms 4016 KB Output is correct
18 Correct 41 ms 3952 KB Output is correct
19 Correct 51 ms 4688 KB Output is correct
20 Correct 51 ms 4432 KB Output is correct
21 Correct 80 ms 5972 KB Output is correct
22 Correct 51 ms 10644 KB Output is correct
23 Correct 55 ms 10776 KB Output is correct
24 Correct 49 ms 5972 KB Output is correct
25 Correct 64 ms 7060 KB Output is correct
26 Correct 44 ms 4700 KB Output is correct
27 Correct 50 ms 4776 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 51 ms 3888 KB Output is correct
30 Correct 46 ms 4180 KB Output is correct
31 Correct 45 ms 4792 KB Output is correct
32 Correct 43 ms 5200 KB Output is correct
33 Correct 47 ms 4436 KB Output is correct
34 Correct 46 ms 4176 KB Output is correct
35 Correct 51 ms 4084 KB Output is correct
36 Correct 42 ms 3924 KB Output is correct
37 Correct 51 ms 4692 KB Output is correct
38 Correct 52 ms 4436 KB Output is correct
39 Correct 84 ms 5716 KB Output is correct
40 Correct 54 ms 10508 KB Output is correct
41 Correct 51 ms 10640 KB Output is correct
42 Correct 49 ms 5972 KB Output is correct
43 Correct 51 ms 6992 KB Output is correct
44 Correct 45 ms 4688 KB Output is correct
45 Correct 45 ms 4668 KB Output is correct
46 Correct 77 ms 12316 KB Output is correct
47 Correct 50 ms 5708 KB Output is correct
48 Correct 100 ms 6736 KB Output is correct
49 Correct 78 ms 55632 KB Output is correct
50 Correct 69 ms 29780 KB Output is correct
51 Correct 76 ms 15952 KB Output is correct
52 Correct 74 ms 36380 KB Output is correct
53 Correct 52 ms 5460 KB Output is correct
54 Correct 49 ms 10324 KB Output is correct
55 Correct 168 ms 6940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 47 ms 1088 KB Output is correct
3 Correct 49 ms 1304 KB Output is correct
4 Correct 47 ms 4692 KB Output is correct
5 Correct 57 ms 5164 KB Output is correct
6 Correct 54 ms 4372 KB Output is correct
7 Correct 56 ms 4228 KB Output is correct
8 Correct 55 ms 4068 KB Output is correct
9 Correct 44 ms 3940 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 46 ms 4040 KB Output is correct
12 Correct 43 ms 4180 KB Output is correct
13 Correct 47 ms 4504 KB Output is correct
14 Correct 45 ms 5160 KB Output is correct
15 Correct 90 ms 4344 KB Output is correct
16 Correct 53 ms 4176 KB Output is correct
17 Correct 44 ms 4016 KB Output is correct
18 Correct 41 ms 3952 KB Output is correct
19 Correct 51 ms 4688 KB Output is correct
20 Correct 51 ms 4432 KB Output is correct
21 Correct 80 ms 5972 KB Output is correct
22 Correct 51 ms 10644 KB Output is correct
23 Correct 55 ms 10776 KB Output is correct
24 Correct 49 ms 5972 KB Output is correct
25 Correct 64 ms 7060 KB Output is correct
26 Correct 44 ms 4700 KB Output is correct
27 Correct 50 ms 4776 KB Output is correct
28 Correct 70 ms 1104 KB Output is correct
29 Correct 68 ms 1108 KB Output is correct
30 Correct 107 ms 1252 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 75 ms 13380 KB Output is correct
33 Correct 74 ms 12368 KB Output is correct
34 Correct 74 ms 13020 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 604 KB Output is correct
37 Correct 45 ms 4024 KB Output is correct
38 Correct 45 ms 3940 KB Output is correct
39 Correct 51 ms 4688 KB Output is correct
40 Correct 43 ms 5204 KB Output is correct
41 Correct 46 ms 4432 KB Output is correct
42 Correct 46 ms 4176 KB Output is correct
43 Correct 45 ms 4088 KB Output is correct
44 Correct 42 ms 4064 KB Output is correct
45 Correct 51 ms 4692 KB Output is correct
46 Correct 47 ms 4440 KB Output is correct
47 Correct 62 ms 5840 KB Output is correct
48 Correct 56 ms 10676 KB Output is correct
49 Correct 51 ms 10576 KB Output is correct
50 Correct 48 ms 5972 KB Output is correct
51 Correct 50 ms 6992 KB Output is correct
52 Correct 46 ms 4692 KB Output is correct
53 Correct 46 ms 4848 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 44 ms 5304 KB Output is correct
56 Correct 58 ms 10300 KB Output is correct
57 Correct 93 ms 12116 KB Output is correct
58 Correct 51 ms 5720 KB Output is correct
59 Correct 90 ms 6704 KB Output is correct
60 Correct 80 ms 20748 KB Output is correct
61 Correct 85 ms 20852 KB Output is correct
62 Correct 80 ms 16212 KB Output is correct
63 Correct 78 ms 13648 KB Output is correct
64 Correct 76 ms 13140 KB Output is correct
65 Correct 79 ms 13128 KB Output is correct
66 Correct 143 ms 13648 KB Output is correct
67 Correct 151 ms 13632 KB Output is correct
68 Correct 74 ms 13908 KB Output is correct
69 Correct 83 ms 14924 KB Output is correct
70 Correct 105 ms 14916 KB Output is correct
71 Correct 99 ms 18000 KB Output is correct
72 Correct 141 ms 18004 KB Output is correct
73 Correct 580 ms 16496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 47 ms 1088 KB Output is correct
3 Correct 49 ms 1304 KB Output is correct
4 Correct 47 ms 4692 KB Output is correct
5 Correct 57 ms 5164 KB Output is correct
6 Correct 54 ms 4372 KB Output is correct
7 Correct 56 ms 4228 KB Output is correct
8 Correct 55 ms 4068 KB Output is correct
9 Correct 44 ms 3940 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 44 ms 3896 KB Output is correct
12 Correct 48 ms 3964 KB Output is correct
13 Correct 50 ms 4548 KB Output is correct
14 Correct 49 ms 5032 KB Output is correct
15 Correct 46 ms 4504 KB Output is correct
16 Correct 49 ms 4128 KB Output is correct
17 Correct 56 ms 4136 KB Output is correct
18 Correct 47 ms 3996 KB Output is correct
19 Correct 65 ms 6576 KB Output is correct
20 Correct 793 ms 136416 KB Output is correct
21 Correct 2217 ms 786004 KB Output is correct
22 Correct 2372 ms 989004 KB Output is correct
23 Correct 742 ms 788124 KB Output is correct
24 Correct 916 ms 991456 KB Output is correct
25 Correct 246 ms 138324 KB Output is correct
26 Correct 84 ms 9556 KB Output is correct
27 Correct 3264 ms 989316 KB Output is correct
28 Execution timed out 4090 ms 988952 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 47 ms 1088 KB Output is correct
3 Correct 49 ms 1304 KB Output is correct
4 Correct 47 ms 4692 KB Output is correct
5 Correct 57 ms 5164 KB Output is correct
6 Correct 54 ms 4372 KB Output is correct
7 Correct 56 ms 4228 KB Output is correct
8 Correct 55 ms 4068 KB Output is correct
9 Correct 44 ms 3940 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 46 ms 4040 KB Output is correct
12 Correct 43 ms 4180 KB Output is correct
13 Correct 47 ms 4504 KB Output is correct
14 Correct 45 ms 5160 KB Output is correct
15 Correct 90 ms 4344 KB Output is correct
16 Correct 53 ms 4176 KB Output is correct
17 Correct 44 ms 4016 KB Output is correct
18 Correct 41 ms 3952 KB Output is correct
19 Correct 51 ms 4688 KB Output is correct
20 Correct 51 ms 4432 KB Output is correct
21 Correct 80 ms 5972 KB Output is correct
22 Correct 51 ms 10644 KB Output is correct
23 Correct 55 ms 10776 KB Output is correct
24 Correct 49 ms 5972 KB Output is correct
25 Correct 64 ms 7060 KB Output is correct
26 Correct 44 ms 4700 KB Output is correct
27 Correct 50 ms 4776 KB Output is correct
28 Correct 70 ms 1104 KB Output is correct
29 Correct 68 ms 1108 KB Output is correct
30 Correct 107 ms 1252 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 51 ms 3888 KB Output is correct
34 Correct 46 ms 4180 KB Output is correct
35 Correct 45 ms 4792 KB Output is correct
36 Correct 43 ms 5200 KB Output is correct
37 Correct 47 ms 4436 KB Output is correct
38 Correct 46 ms 4176 KB Output is correct
39 Correct 51 ms 4084 KB Output is correct
40 Correct 42 ms 3924 KB Output is correct
41 Correct 51 ms 4692 KB Output is correct
42 Correct 52 ms 4436 KB Output is correct
43 Correct 84 ms 5716 KB Output is correct
44 Correct 54 ms 10508 KB Output is correct
45 Correct 51 ms 10640 KB Output is correct
46 Correct 49 ms 5972 KB Output is correct
47 Correct 51 ms 6992 KB Output is correct
48 Correct 45 ms 4688 KB Output is correct
49 Correct 45 ms 4668 KB Output is correct
50 Correct 77 ms 12316 KB Output is correct
51 Correct 50 ms 5708 KB Output is correct
52 Correct 100 ms 6736 KB Output is correct
53 Correct 78 ms 55632 KB Output is correct
54 Correct 69 ms 29780 KB Output is correct
55 Correct 76 ms 15952 KB Output is correct
56 Correct 74 ms 36380 KB Output is correct
57 Correct 52 ms 5460 KB Output is correct
58 Correct 49 ms 10324 KB Output is correct
59 Correct 168 ms 6940 KB Output is correct
60 Correct 75 ms 13380 KB Output is correct
61 Correct 74 ms 12368 KB Output is correct
62 Correct 74 ms 13020 KB Output is correct
63 Correct 0 ms 348 KB Output is correct
64 Correct 0 ms 604 KB Output is correct
65 Correct 45 ms 4024 KB Output is correct
66 Correct 45 ms 3940 KB Output is correct
67 Correct 51 ms 4688 KB Output is correct
68 Correct 43 ms 5204 KB Output is correct
69 Correct 46 ms 4432 KB Output is correct
70 Correct 46 ms 4176 KB Output is correct
71 Correct 45 ms 4088 KB Output is correct
72 Correct 42 ms 4064 KB Output is correct
73 Correct 51 ms 4692 KB Output is correct
74 Correct 47 ms 4440 KB Output is correct
75 Correct 62 ms 5840 KB Output is correct
76 Correct 56 ms 10676 KB Output is correct
77 Correct 51 ms 10576 KB Output is correct
78 Correct 48 ms 5972 KB Output is correct
79 Correct 50 ms 6992 KB Output is correct
80 Correct 46 ms 4692 KB Output is correct
81 Correct 46 ms 4848 KB Output is correct
82 Correct 0 ms 348 KB Output is correct
83 Correct 44 ms 5304 KB Output is correct
84 Correct 58 ms 10300 KB Output is correct
85 Correct 93 ms 12116 KB Output is correct
86 Correct 51 ms 5720 KB Output is correct
87 Correct 90 ms 6704 KB Output is correct
88 Correct 80 ms 20748 KB Output is correct
89 Correct 85 ms 20852 KB Output is correct
90 Correct 80 ms 16212 KB Output is correct
91 Correct 78 ms 13648 KB Output is correct
92 Correct 76 ms 13140 KB Output is correct
93 Correct 79 ms 13128 KB Output is correct
94 Correct 143 ms 13648 KB Output is correct
95 Correct 151 ms 13632 KB Output is correct
96 Correct 74 ms 13908 KB Output is correct
97 Correct 83 ms 14924 KB Output is correct
98 Correct 105 ms 14916 KB Output is correct
99 Correct 99 ms 18000 KB Output is correct
100 Correct 141 ms 18004 KB Output is correct
101 Correct 580 ms 16496 KB Output is correct
102 Correct 0 ms 604 KB Output is correct
103 Correct 44 ms 3896 KB Output is correct
104 Correct 48 ms 3964 KB Output is correct
105 Correct 50 ms 4548 KB Output is correct
106 Correct 49 ms 5032 KB Output is correct
107 Correct 46 ms 4504 KB Output is correct
108 Correct 49 ms 4128 KB Output is correct
109 Correct 56 ms 4136 KB Output is correct
110 Correct 47 ms 3996 KB Output is correct
111 Correct 65 ms 6576 KB Output is correct
112 Correct 793 ms 136416 KB Output is correct
113 Correct 2217 ms 786004 KB Output is correct
114 Correct 2372 ms 989004 KB Output is correct
115 Correct 742 ms 788124 KB Output is correct
116 Correct 916 ms 991456 KB Output is correct
117 Correct 246 ms 138324 KB Output is correct
118 Correct 84 ms 9556 KB Output is correct
119 Correct 3264 ms 989316 KB Output is correct
120 Execution timed out 4090 ms 988952 KB Time limit exceeded
121 Halted 0 ms 0 KB -