#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=200050;
const int lim=1e9;
array<int,4> rec[N],ans[4];
array<int,4> sec(array<int,4> a,array<int,4> b){
return {max(a[0],b[0]),max(a[1],b[1]),min(a[2],b[2]),min(a[3],b[3])};
}
bool is_valid(array<int,4> x){
return x[0]<=x[2]&&x[1]<=x[3];
}
int main(){
int n,k;
scanf("%i %i",&n,&k);
vector<int> ids;
for(int i=1;i<=n;i++){
scanf("%i %i %i %i",&rec[i][0],&rec[i][1],&rec[i][2],&rec[i][3]);
ids.pb(i);
}
mt19937 rng(time(0));
shuffle(ids.begin(),ids.end(),rng);
while(1){
vector<int> v[2];
for(int i=0;i<k;i++)ans[i]={1,1,lim,lim};
for(int i:ids){
bool ok=0;
for(int j=0;j<k;j++){
if(is_valid(sec(ans[j],rec[i]))){
ans[j]=sec(ans[j],rec[i]);
ok=1;v[0].pb(i);
break;
}
}
if(!ok)v[1].pb(i);
}
if(v[1].empty()){
for(int i=0;i<k;i++)printf("%i %i\n",ans[i][0],ans[i][1]);
return 0;
}
ids=v[1];
shuffle(ids.begin(),ids.end(),rng);
for(int i:v[0])ids.pb(i);
}
return 0;
}
Compilation message
hamburg.cpp: In function 'int main()':
hamburg.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
15 | scanf("%i %i",&n,&k);
| ~~~~~^~~~~~~~~~~~~~~
hamburg.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
18 | scanf("%i %i %i %i",&rec[i][0],&rec[i][1],&rec[i][2],&rec[i][3]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 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 |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
416 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 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 |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
2 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
3 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
3 ms |
384 KB |
Output is correct |
38 |
Correct |
2 ms |
384 KB |
Output is correct |
39 |
Correct |
2 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 |
2 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
384 KB |
Output is correct |
44 |
Correct |
2 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 |
2 ms |
384 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
2 ms |
384 KB |
Output is correct |
50 |
Correct |
2 ms |
384 KB |
Output is correct |
51 |
Correct |
3 ms |
384 KB |
Output is correct |
52 |
Correct |
3 ms |
384 KB |
Output is correct |
53 |
Correct |
2 ms |
384 KB |
Output is correct |
54 |
Correct |
2 ms |
384 KB |
Output is correct |
55 |
Correct |
3 ms |
384 KB |
Output is correct |
56 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
167 ms |
5780 KB |
Output is correct |
6 |
Correct |
223 ms |
5796 KB |
Output is correct |
7 |
Correct |
159 ms |
5740 KB |
Output is correct |
8 |
Correct |
150 ms |
5740 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
158 ms |
6092 KB |
Output is correct |
6 |
Correct |
166 ms |
6100 KB |
Output is correct |
7 |
Correct |
165 ms |
6076 KB |
Output is correct |
8 |
Correct |
161 ms |
6032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
3 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 |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
416 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
163 ms |
5996 KB |
Output is correct |
14 |
Correct |
167 ms |
6080 KB |
Output is correct |
15 |
Correct |
165 ms |
6004 KB |
Output is correct |
16 |
Correct |
164 ms |
6092 KB |
Output is correct |
17 |
Correct |
171 ms |
6032 KB |
Output is correct |
18 |
Correct |
155 ms |
6072 KB |
Output is correct |
19 |
Correct |
164 ms |
6020 KB |
Output is correct |
20 |
Correct |
186 ms |
6028 KB |
Output is correct |
21 |
Correct |
184 ms |
6132 KB |
Output is correct |
22 |
Correct |
177 ms |
6020 KB |
Output is correct |
23 |
Correct |
177 ms |
6028 KB |
Output is correct |
24 |
Correct |
166 ms |
6180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 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 |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
384 KB |
Output is correct |
26 |
Correct |
2 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
3 ms |
384 KB |
Output is correct |
35 |
Correct |
3 ms |
384 KB |
Output is correct |
36 |
Correct |
2 ms |
384 KB |
Output is correct |
37 |
Correct |
3 ms |
384 KB |
Output is correct |
38 |
Correct |
2 ms |
384 KB |
Output is correct |
39 |
Correct |
2 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 |
2 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
384 KB |
Output is correct |
44 |
Correct |
2 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 |
2 ms |
384 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
2 ms |
384 KB |
Output is correct |
50 |
Correct |
2 ms |
384 KB |
Output is correct |
51 |
Correct |
3 ms |
384 KB |
Output is correct |
52 |
Correct |
3 ms |
384 KB |
Output is correct |
53 |
Correct |
2 ms |
384 KB |
Output is correct |
54 |
Correct |
2 ms |
384 KB |
Output is correct |
55 |
Correct |
3 ms |
384 KB |
Output is correct |
56 |
Correct |
3 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 |
158 ms |
6104 KB |
Output is correct |
60 |
Correct |
172 ms |
6116 KB |
Output is correct |
61 |
Correct |
183 ms |
6052 KB |
Output is correct |
62 |
Correct |
173 ms |
5988 KB |
Output is correct |
63 |
Correct |
181 ms |
6092 KB |
Output is correct |
64 |
Correct |
161 ms |
6368 KB |
Output is correct |
65 |
Correct |
191 ms |
6012 KB |
Output is correct |
66 |
Correct |
188 ms |
6100 KB |
Output is correct |
67 |
Correct |
195 ms |
6120 KB |
Output is correct |
68 |
Correct |
196 ms |
6040 KB |
Output is correct |
69 |
Correct |
171 ms |
6064 KB |
Output is correct |
70 |
Correct |
198 ms |
6124 KB |
Output is correct |
71 |
Correct |
166 ms |
6088 KB |
Output is correct |
72 |
Correct |
181 ms |
6076 KB |
Output is correct |
73 |
Correct |
182 ms |
6060 KB |
Output is correct |
74 |
Correct |
217 ms |
6080 KB |
Output is correct |
75 |
Correct |
177 ms |
6060 KB |
Output is correct |
76 |
Correct |
174 ms |
6176 KB |
Output is correct |
77 |
Correct |
175 ms |
6120 KB |
Output is correct |
78 |
Correct |
185 ms |
6088 KB |
Output is correct |
79 |
Correct |
192 ms |
6060 KB |
Output is correct |
80 |
Correct |
220 ms |
6164 KB |
Output is correct |
81 |
Correct |
251 ms |
6072 KB |
Output is correct |
82 |
Correct |
166 ms |
5996 KB |
Output is correct |
83 |
Correct |
169 ms |
6048 KB |
Output is correct |
84 |
Correct |
161 ms |
6176 KB |
Output is correct |
85 |
Correct |
181 ms |
6112 KB |
Output is correct |
86 |
Correct |
203 ms |
6332 KB |
Output is correct |
87 |
Correct |
187 ms |
6072 KB |
Output is correct |
88 |
Correct |
168 ms |
6024 KB |
Output is correct |
89 |
Correct |
211 ms |
6052 KB |
Output is correct |
90 |
Correct |
190 ms |
6100 KB |
Output is correct |
91 |
Correct |
194 ms |
6100 KB |
Output is correct |
92 |
Correct |
208 ms |
6068 KB |
Output is correct |
93 |
Correct |
215 ms |
6100 KB |
Output is correct |
94 |
Correct |
249 ms |
6028 KB |
Output is correct |
95 |
Correct |
206 ms |
6108 KB |
Output is correct |
96 |
Correct |
237 ms |
6120 KB |
Output is correct |
97 |
Correct |
177 ms |
6004 KB |
Output is correct |
98 |
Correct |
192 ms |
6084 KB |
Output is correct |
99 |
Correct |
222 ms |
6120 KB |
Output is correct |
100 |
Correct |
213 ms |
6088 KB |
Output is correct |
101 |
Correct |
181 ms |
6076 KB |
Output is correct |
102 |
Correct |
174 ms |
6104 KB |
Output is correct |
103 |
Correct |
175 ms |
6028 KB |
Output is correct |
104 |
Correct |
191 ms |
6032 KB |
Output is correct |
105 |
Correct |
198 ms |
6100 KB |
Output is correct |
106 |
Correct |
187 ms |
6068 KB |
Output is correct |
107 |
Correct |
172 ms |
6072 KB |
Output is correct |
108 |
Correct |
182 ms |
6020 KB |
Output is correct |
109 |
Correct |
194 ms |
6052 KB |
Output is correct |
110 |
Correct |
203 ms |
6124 KB |
Output is correct |
111 |
Correct |
193 ms |
6088 KB |
Output is correct |
112 |
Correct |
192 ms |
6068 KB |
Output is correct |
113 |
Correct |
207 ms |
6096 KB |
Output is correct |
114 |
Correct |
159 ms |
5740 KB |
Output is correct |
115 |
Correct |
147 ms |
5704 KB |
Output is correct |
116 |
Correct |
168 ms |
6028 KB |
Output is correct |
117 |
Execution timed out |
3066 ms |
6276 KB |
Time limit exceeded |
118 |
Halted |
0 ms |
0 KB |
- |