#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_ < 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:52:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%d%d", &n, &k);
| ^~~~~~~~~~~~~~~~~~~~~
hamburg.c:54:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | 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 |
392 KB |
Output is correct |
3 |
Correct |
1 ms |
304 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 |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
388 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 |
2 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 |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
680 ms |
396 KB |
Output is correct |
3 |
Correct |
241 ms |
340 KB |
Output is correct |
4 |
Correct |
87 ms |
404 KB |
Output is correct |
5 |
Correct |
201 ms |
416 KB |
Output is correct |
6 |
Correct |
39 ms |
340 KB |
Output is correct |
7 |
Correct |
202 ms |
404 KB |
Output is correct |
8 |
Correct |
139 ms |
340 KB |
Output is correct |
9 |
Correct |
385 ms |
396 KB |
Output is correct |
10 |
Correct |
63 ms |
340 KB |
Output is correct |
11 |
Correct |
2082 ms |
412 KB |
Output is correct |
12 |
Correct |
15 ms |
340 KB |
Output is correct |
13 |
Correct |
1805 ms |
396 KB |
Output is correct |
14 |
Correct |
643 ms |
412 KB |
Output is correct |
15 |
Correct |
410 ms |
404 KB |
Output is correct |
16 |
Correct |
1106 ms |
400 KB |
Output is correct |
17 |
Correct |
212 ms |
400 KB |
Output is correct |
18 |
Execution timed out |
3086 ms |
340 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
392 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 |
4740 KB |
Output is correct |
6 |
Correct |
94 ms |
4452 KB |
Output is correct |
7 |
Correct |
83 ms |
4624 KB |
Output is correct |
8 |
Correct |
83 ms |
4536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
388 KB |
Output is correct |
5 |
Correct |
86 ms |
4556 KB |
Output is correct |
6 |
Correct |
93 ms |
4520 KB |
Output is correct |
7 |
Correct |
94 ms |
4592 KB |
Output is correct |
8 |
Correct |
97 ms |
4504 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 |
2 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 |
3 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
340 KB |
Output is correct |
13 |
Correct |
91 ms |
4564 KB |
Output is correct |
14 |
Correct |
92 ms |
4560 KB |
Output is correct |
15 |
Correct |
86 ms |
4572 KB |
Output is correct |
16 |
Correct |
91 ms |
4252 KB |
Output is correct |
17 |
Correct |
93 ms |
4328 KB |
Output is correct |
18 |
Correct |
87 ms |
4296 KB |
Output is correct |
19 |
Correct |
91 ms |
4260 KB |
Output is correct |
20 |
Correct |
106 ms |
4320 KB |
Output is correct |
21 |
Correct |
261 ms |
4424 KB |
Output is correct |
22 |
Correct |
180 ms |
4200 KB |
Output is correct |
23 |
Correct |
141 ms |
4324 KB |
Output is correct |
24 |
Correct |
151 ms |
4044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
340 KB |
Output is correct |
2 |
Correct |
680 ms |
396 KB |
Output is correct |
3 |
Correct |
241 ms |
340 KB |
Output is correct |
4 |
Correct |
87 ms |
404 KB |
Output is correct |
5 |
Correct |
201 ms |
416 KB |
Output is correct |
6 |
Correct |
39 ms |
340 KB |
Output is correct |
7 |
Correct |
202 ms |
404 KB |
Output is correct |
8 |
Correct |
139 ms |
340 KB |
Output is correct |
9 |
Correct |
385 ms |
396 KB |
Output is correct |
10 |
Correct |
63 ms |
340 KB |
Output is correct |
11 |
Correct |
2082 ms |
412 KB |
Output is correct |
12 |
Correct |
15 ms |
340 KB |
Output is correct |
13 |
Correct |
1805 ms |
396 KB |
Output is correct |
14 |
Correct |
643 ms |
412 KB |
Output is correct |
15 |
Correct |
410 ms |
404 KB |
Output is correct |
16 |
Correct |
1106 ms |
400 KB |
Output is correct |
17 |
Correct |
212 ms |
400 KB |
Output is correct |
18 |
Execution timed out |
3086 ms |
340 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |