#include<bits/stdc++.h>
#define ll long long
#define fo(i,x,y) for(int i=x; i<=y; i++)
using namespace std;
const int N = 2e5 + 5;
int n,k;
struct P {
ll x1,y1,x2,y2;
} a[N];
ll query(P a) {
if (a.x1 > a.x2)
return 0;
if (a.y1 > a.y2)
return 0;
return (a.x2 - a.x1 + 1) * (a.y2 - a.y1 + 1);
}
P merge(P a,P b) {
a.x1 = max(a.x1,b.x1);
a.y1 = max(a.y1,b.y1);
a.x2 = min(a.x2,b.x2);
a.y2 = min(a.y2,b.y2);
return a;
}
P b[5];
#define db double
db calc(P a,P b)
{
db s = query(a),s2 = query(merge(a,b));
return (db)(s - s2) / s;
}
int main()
{
srand(time(NULL));
scanf("%d %d",&n,&k);
fo(i,1,n)
{
scanf("%lld %lld %lld %lld",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);
}
k = min(k,n);
while (1)
{
int bz = 1;
random_shuffle(a + 1,a + n + 1);
fo(i,1,k) b[i] = a[i];
fo(i,k + 1,n) {
int x = 1;
db y = 1e9;
fo(j,1,k) {
db v = calc(b[j],a[i]);
if (v < y)
x = j,y = v;
}
b[x] = merge(b[x],a[i]);
if (query(b[x]) == 0) {
bz = 0;
break;
}
}
if (bz)
{
fo(i,1,k) printf("%lld %lld\n",b[i].x1,b[i].y1);
break;
}
}
}
Compilation message
hamburg.cpp: In function 'int main()':
hamburg.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
43 | scanf("%d %d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~~
hamburg.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
46 | scanf("%lld %lld %lld %lld",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
416 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
416 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
416 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
8 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
6 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
4 ms |
384 KB |
Output is correct |
26 |
Correct |
10 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
4 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
360 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
6 ms |
384 KB |
Output is correct |
39 |
Correct |
4 ms |
384 KB |
Output is correct |
40 |
Correct |
2 ms |
384 KB |
Output is correct |
41 |
Correct |
2 ms |
384 KB |
Output is correct |
42 |
Correct |
4 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
384 KB |
Output is correct |
44 |
Correct |
3 ms |
384 KB |
Output is correct |
45 |
Correct |
2 ms |
384 KB |
Output is correct |
46 |
Correct |
2 ms |
384 KB |
Output is correct |
47 |
Correct |
3 ms |
384 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
4 ms |
384 KB |
Output is correct |
50 |
Correct |
4 ms |
384 KB |
Output is correct |
51 |
Correct |
4 ms |
384 KB |
Output is correct |
52 |
Correct |
3 ms |
384 KB |
Output is correct |
53 |
Correct |
3 ms |
384 KB |
Output is correct |
54 |
Correct |
2 ms |
512 KB |
Output is correct |
55 |
Correct |
2 ms |
384 KB |
Output is correct |
56 |
Correct |
2 ms |
384 KB |
Output is correct |
57 |
Correct |
2 ms |
384 KB |
Output is correct |
58 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
173 ms |
6540 KB |
Output is correct |
6 |
Correct |
150 ms |
6660 KB |
Output is correct |
7 |
Correct |
160 ms |
6596 KB |
Output is correct |
8 |
Correct |
161 ms |
6520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
154 ms |
6524 KB |
Output is correct |
6 |
Correct |
225 ms |
6568 KB |
Output is correct |
7 |
Correct |
171 ms |
6636 KB |
Output is correct |
8 |
Correct |
215 ms |
6632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
432 KB |
Output is correct |
13 |
Correct |
235 ms |
6556 KB |
Output is correct |
14 |
Correct |
156 ms |
6520 KB |
Output is correct |
15 |
Correct |
235 ms |
6648 KB |
Output is correct |
16 |
Correct |
196 ms |
6520 KB |
Output is correct |
17 |
Correct |
231 ms |
6520 KB |
Output is correct |
18 |
Correct |
167 ms |
6540 KB |
Output is correct |
19 |
Correct |
238 ms |
6520 KB |
Output is correct |
20 |
Correct |
208 ms |
6516 KB |
Output is correct |
21 |
Correct |
176 ms |
6552 KB |
Output is correct |
22 |
Correct |
217 ms |
6520 KB |
Output is correct |
23 |
Correct |
187 ms |
6524 KB |
Output is correct |
24 |
Correct |
259 ms |
6672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
416 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
416 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
416 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
8 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
3 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
6 ms |
384 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
4 ms |
384 KB |
Output is correct |
26 |
Correct |
10 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
4 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
360 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
2 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
5 ms |
384 KB |
Output is correct |
38 |
Correct |
6 ms |
384 KB |
Output is correct |
39 |
Correct |
4 ms |
384 KB |
Output is correct |
40 |
Correct |
2 ms |
384 KB |
Output is correct |
41 |
Correct |
2 ms |
384 KB |
Output is correct |
42 |
Correct |
4 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
384 KB |
Output is correct |
44 |
Correct |
3 ms |
384 KB |
Output is correct |
45 |
Correct |
2 ms |
384 KB |
Output is correct |
46 |
Correct |
2 ms |
384 KB |
Output is correct |
47 |
Correct |
3 ms |
384 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
4 ms |
384 KB |
Output is correct |
50 |
Correct |
4 ms |
384 KB |
Output is correct |
51 |
Correct |
4 ms |
384 KB |
Output is correct |
52 |
Correct |
3 ms |
384 KB |
Output is correct |
53 |
Correct |
3 ms |
384 KB |
Output is correct |
54 |
Correct |
2 ms |
512 KB |
Output is correct |
55 |
Correct |
2 ms |
384 KB |
Output is correct |
56 |
Correct |
2 ms |
384 KB |
Output is correct |
57 |
Correct |
2 ms |
384 KB |
Output is correct |
58 |
Correct |
2 ms |
384 KB |
Output is correct |
59 |
Correct |
201 ms |
6588 KB |
Output is correct |
60 |
Correct |
220 ms |
6564 KB |
Output is correct |
61 |
Correct |
182 ms |
6520 KB |
Output is correct |
62 |
Correct |
166 ms |
6576 KB |
Output is correct |
63 |
Correct |
183 ms |
6520 KB |
Output is correct |
64 |
Correct |
155 ms |
6520 KB |
Output is correct |
65 |
Correct |
611 ms |
6520 KB |
Output is correct |
66 |
Correct |
348 ms |
6624 KB |
Output is correct |
67 |
Correct |
250 ms |
6564 KB |
Output is correct |
68 |
Correct |
185 ms |
6520 KB |
Output is correct |
69 |
Correct |
230 ms |
6700 KB |
Output is correct |
70 |
Correct |
238 ms |
6520 KB |
Output is correct |
71 |
Correct |
366 ms |
6520 KB |
Output is correct |
72 |
Correct |
300 ms |
6520 KB |
Output is correct |
73 |
Correct |
416 ms |
6624 KB |
Output is correct |
74 |
Correct |
561 ms |
6616 KB |
Output is correct |
75 |
Correct |
353 ms |
6640 KB |
Output is correct |
76 |
Correct |
379 ms |
6620 KB |
Output is correct |
77 |
Correct |
217 ms |
6596 KB |
Output is correct |
78 |
Correct |
397 ms |
6616 KB |
Output is correct |
79 |
Correct |
243 ms |
6524 KB |
Output is correct |
80 |
Correct |
353 ms |
6620 KB |
Output is correct |
81 |
Correct |
401 ms |
6624 KB |
Output is correct |
82 |
Correct |
367 ms |
6620 KB |
Output is correct |
83 |
Correct |
299 ms |
6520 KB |
Output is correct |
84 |
Correct |
331 ms |
6520 KB |
Output is correct |
85 |
Correct |
304 ms |
6520 KB |
Output is correct |
86 |
Correct |
341 ms |
6648 KB |
Output is correct |
87 |
Correct |
301 ms |
6620 KB |
Output is correct |
88 |
Correct |
188 ms |
6524 KB |
Output is correct |
89 |
Correct |
202 ms |
6520 KB |
Output is correct |
90 |
Correct |
535 ms |
6520 KB |
Output is correct |
91 |
Correct |
197 ms |
6520 KB |
Output is correct |
92 |
Correct |
1332 ms |
6648 KB |
Output is correct |
93 |
Correct |
503 ms |
6696 KB |
Output is correct |
94 |
Correct |
328 ms |
6520 KB |
Output is correct |
95 |
Correct |
239 ms |
6600 KB |
Output is correct |
96 |
Correct |
216 ms |
6520 KB |
Output is correct |
97 |
Correct |
210 ms |
6520 KB |
Output is correct |
98 |
Correct |
304 ms |
6616 KB |
Output is correct |
99 |
Correct |
438 ms |
6648 KB |
Output is correct |
100 |
Correct |
348 ms |
6624 KB |
Output is correct |
101 |
Correct |
274 ms |
6592 KB |
Output is correct |
102 |
Correct |
302 ms |
6608 KB |
Output is correct |
103 |
Correct |
258 ms |
6560 KB |
Output is correct |
104 |
Correct |
454 ms |
6520 KB |
Output is correct |
105 |
Correct |
341 ms |
6648 KB |
Output is correct |
106 |
Correct |
222 ms |
6648 KB |
Output is correct |
107 |
Correct |
509 ms |
6520 KB |
Output is correct |
108 |
Correct |
1167 ms |
6616 KB |
Output is correct |
109 |
Correct |
332 ms |
6704 KB |
Output is correct |
110 |
Correct |
173 ms |
6520 KB |
Output is correct |
111 |
Correct |
526 ms |
6616 KB |
Output is correct |
112 |
Correct |
1521 ms |
6624 KB |
Output is correct |
113 |
Correct |
353 ms |
6520 KB |
Output is correct |
114 |
Correct |
244 ms |
6616 KB |
Output is correct |
115 |
Correct |
293 ms |
6520 KB |
Output is correct |
116 |
Correct |
164 ms |
6520 KB |
Output is correct |
117 |
Execution timed out |
3100 ms |
6520 KB |
Time limit exceeded |
118 |
Halted |
0 ms |
0 KB |
- |