답안 #670023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670023 2022-12-07T19:21:44 Z rainboy 함박 스테이크 (JOI20_hamburg) C
21 / 100
3000 ms 11088 KB
#include <stdio.h>
#include <stdlib.h>

#define N	200000
#define INF	0x3f3f3f3f

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

int xx1[N], xx2[N], yy1[N], yy2[N], xx[N], yy[N], n;

int pierced(int i, int k) {
	int h;

	for (h = 0; h < k; h++)
		if (xx1[i] <= xx[h] && xx[h] <= xx2[i] && yy1[i] <= yy[h] && yy[h] <= yy2[i])
			return 1;
	return 0;
}

void solve(int k_, int k) {
	int h, i, x1, x2, y1, y2;

	x1 = INF, x2 = -1, y1 = INF, y2 = -1;
	for (i = 0; i < n; i++)
		if (!pierced(i, k_)) {
			x1 = min(x1, xx2[i]), x2 = max(x2, xx1[i]);
			y1 = min(y1, yy2[i]), y2 = max(y2, yy1[i]);
		}
	if (x1 == INF) {
		for (h = k_; h < k; h++)
			xx[h] = 1, yy[h] = 1;
		for (h = 0; h < k; h++)
			printf("%d %d\n", xx[h], yy[h]);
		exit(0);
	} else if (k_ < k) {
		if (k - k_ == 1)
			xx[k_] = x1, yy[k_] = y1, solve(k_ + 1, k);
		else if (k - k_ < 4) {
			xx[k_] = x1, yy[k_] = y1, solve(k_ + 1, k);
			xx[k_] = x1, yy[k_] = y2, solve(k_ + 1, k);
			xx[k_] = x2, yy[k_] = y1, solve(k_ + 1, k);
			xx[k_] = x2, yy[k_] = y2, solve(k_ + 1, k);
		} else {
			for (i = 0; i < n; i++)
				xx[k_] = xx1[i], yy[k_] = y1, solve(k_ + 1, k);
		}
	}
}

int main() {
	int k, i;

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++)
		scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]);
	solve(0, k);
	return 0;
}

Compilation message

hamburg.c: In function 'main':
hamburg.c:54:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
hamburg.c:56:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |   scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 303 ms 320 KB Output is correct
3 Correct 110 ms 340 KB Output is correct
4 Correct 38 ms 212 KB Output is correct
5 Correct 86 ms 340 KB Output is correct
6 Correct 18 ms 340 KB Output is correct
7 Correct 87 ms 340 KB Output is correct
8 Correct 61 ms 340 KB Output is correct
9 Correct 168 ms 340 KB Output is correct
10 Correct 28 ms 340 KB Output is correct
11 Correct 888 ms 340 KB Output is correct
12 Correct 7 ms 340 KB Output is correct
13 Correct 761 ms 320 KB Output is correct
14 Correct 273 ms 340 KB Output is correct
15 Correct 174 ms 212 KB Output is correct
16 Correct 470 ms 340 KB Output is correct
17 Correct 92 ms 212 KB Output is correct
18 Correct 1830 ms 320 KB Output is correct
19 Correct 123 ms 396 KB Output is correct
20 Correct 507 ms 396 KB Output is correct
21 Correct 91 ms 400 KB Output is correct
22 Correct 1465 ms 400 KB Output is correct
23 Correct 265 ms 400 KB Output is correct
24 Correct 360 ms 396 KB Output is correct
25 Correct 504 ms 400 KB Output is correct
26 Correct 154 ms 408 KB Output is correct
27 Correct 169 ms 400 KB Output is correct
28 Correct 1191 ms 412 KB Output is correct
29 Correct 1347 ms 340 KB Output is correct
30 Correct 934 ms 396 KB Output is correct
31 Correct 990 ms 396 KB Output is correct
32 Correct 331 ms 392 KB Output is correct
33 Correct 1541 ms 396 KB Output is correct
34 Correct 271 ms 340 KB Output is correct
35 Correct 61 ms 400 KB Output is correct
36 Correct 237 ms 340 KB Output is correct
37 Correct 42 ms 404 KB Output is correct
38 Correct 1055 ms 308 KB Output is correct
39 Correct 227 ms 300 KB Output is correct
40 Correct 393 ms 400 KB Output is correct
41 Correct 505 ms 340 KB Output is correct
42 Correct 88 ms 392 KB Output is correct
43 Correct 874 ms 400 KB Output is correct
44 Correct 243 ms 400 KB Output is correct
45 Correct 351 ms 400 KB Output is correct
46 Correct 520 ms 340 KB Output is correct
47 Correct 5 ms 340 KB Output is correct
48 Correct 46 ms 396 KB Output is correct
49 Correct 1828 ms 404 KB Output is correct
50 Correct 63 ms 340 KB Output is correct
51 Correct 466 ms 400 KB Output is correct
52 Correct 93 ms 304 KB Output is correct
53 Correct 508 ms 412 KB Output is correct
54 Correct 97 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 388 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 13 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 76 ms 3404 KB Output is correct
6 Correct 73 ms 3360 KB Output is correct
7 Correct 78 ms 3336 KB Output is correct
8 Correct 73 ms 3320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 76 ms 3388 KB Output is correct
6 Correct 77 ms 3292 KB Output is correct
7 Correct 80 ms 3380 KB Output is correct
8 Correct 80 ms 3372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 85 ms 3336 KB Output is correct
14 Correct 78 ms 3364 KB Output is correct
15 Correct 79 ms 3288 KB Output is correct
16 Correct 84 ms 3360 KB Output is correct
17 Correct 80 ms 3408 KB Output is correct
18 Correct 80 ms 3284 KB Output is correct
19 Correct 82 ms 3396 KB Output is correct
20 Correct 85 ms 3336 KB Output is correct
21 Correct 148 ms 3404 KB Output is correct
22 Correct 114 ms 3372 KB Output is correct
23 Correct 106 ms 3404 KB Output is correct
24 Correct 107 ms 3368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 303 ms 320 KB Output is correct
3 Correct 110 ms 340 KB Output is correct
4 Correct 38 ms 212 KB Output is correct
5 Correct 86 ms 340 KB Output is correct
6 Correct 18 ms 340 KB Output is correct
7 Correct 87 ms 340 KB Output is correct
8 Correct 61 ms 340 KB Output is correct
9 Correct 168 ms 340 KB Output is correct
10 Correct 28 ms 340 KB Output is correct
11 Correct 888 ms 340 KB Output is correct
12 Correct 7 ms 340 KB Output is correct
13 Correct 761 ms 320 KB Output is correct
14 Correct 273 ms 340 KB Output is correct
15 Correct 174 ms 212 KB Output is correct
16 Correct 470 ms 340 KB Output is correct
17 Correct 92 ms 212 KB Output is correct
18 Correct 1830 ms 320 KB Output is correct
19 Correct 123 ms 396 KB Output is correct
20 Correct 507 ms 396 KB Output is correct
21 Correct 91 ms 400 KB Output is correct
22 Correct 1465 ms 400 KB Output is correct
23 Correct 265 ms 400 KB Output is correct
24 Correct 360 ms 396 KB Output is correct
25 Correct 504 ms 400 KB Output is correct
26 Correct 154 ms 408 KB Output is correct
27 Correct 169 ms 400 KB Output is correct
28 Correct 1191 ms 412 KB Output is correct
29 Correct 1347 ms 340 KB Output is correct
30 Correct 934 ms 396 KB Output is correct
31 Correct 990 ms 396 KB Output is correct
32 Correct 331 ms 392 KB Output is correct
33 Correct 1541 ms 396 KB Output is correct
34 Correct 271 ms 340 KB Output is correct
35 Correct 61 ms 400 KB Output is correct
36 Correct 237 ms 340 KB Output is correct
37 Correct 42 ms 404 KB Output is correct
38 Correct 1055 ms 308 KB Output is correct
39 Correct 227 ms 300 KB Output is correct
40 Correct 393 ms 400 KB Output is correct
41 Correct 505 ms 340 KB Output is correct
42 Correct 88 ms 392 KB Output is correct
43 Correct 874 ms 400 KB Output is correct
44 Correct 243 ms 400 KB Output is correct
45 Correct 351 ms 400 KB Output is correct
46 Correct 520 ms 340 KB Output is correct
47 Correct 5 ms 340 KB Output is correct
48 Correct 46 ms 396 KB Output is correct
49 Correct 1828 ms 404 KB Output is correct
50 Correct 63 ms 340 KB Output is correct
51 Correct 466 ms 400 KB Output is correct
52 Correct 93 ms 304 KB Output is correct
53 Correct 508 ms 412 KB Output is correct
54 Correct 97 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 388 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 13 ms 340 KB Output is correct
59 Execution timed out 3051 ms 11088 KB Time limit exceeded
60 Halted 0 ms 0 KB -