Submission #670021

# Submission time Handle Problem Language Result Execution time Memory
670021 2022-12-07T19:16:21 Z rainboy Hamburg Steak (JOI20_hamburg) C
15 / 100
249 ms 11148 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) {
		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);
	}
}

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:47:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
hamburg.c:49:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |   scanf("%d%d%d%d", &xx1[i], &yy1[i], &xx2[i], &yy2[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 392 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 300 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 308 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 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 3 ms 428 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 3 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 408 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 436 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 9 ms 340 KB Output is correct
14 Incorrect 10 ms 304 KB Unexpected end of file - int32 expected
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 392 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 86 ms 11052 KB Output is correct
6 Correct 81 ms 11088 KB Output is correct
7 Correct 84 ms 11136 KB Output is correct
8 Correct 82 ms 11140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 300 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 88 ms 11032 KB Output is correct
6 Correct 101 ms 11136 KB Output is correct
7 Correct 84 ms 11128 KB Output is correct
8 Correct 98 ms 11088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 308 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 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 3 ms 428 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 3 ms 392 KB Output is correct
13 Correct 92 ms 11128 KB Output is correct
14 Correct 90 ms 11124 KB Output is correct
15 Correct 85 ms 11020 KB Output is correct
16 Correct 84 ms 11048 KB Output is correct
17 Correct 86 ms 11116 KB Output is correct
18 Correct 83 ms 11032 KB Output is correct
19 Correct 87 ms 11136 KB Output is correct
20 Correct 104 ms 11100 KB Output is correct
21 Correct 249 ms 11016 KB Output is correct
22 Correct 163 ms 11148 KB Output is correct
23 Correct 135 ms 11144 KB Output is correct
24 Correct 151 ms 11140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 408 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 436 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 9 ms 340 KB Output is correct
14 Incorrect 10 ms 304 KB Unexpected end of file - int32 expected
15 Halted 0 ms 0 KB -