#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(int i=j;i<k;++i)
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
struct nd{
int l,d,r,u;
};
const int maxn=2e5+9;
int n,p,pm[maxn];
vector<nd>a,b;
pii res[5];
bitset<maxn>vis;
mt19937 rd(time(0));
nd merge(nd x,nd y){
return nd{max(x.l,y.l),max(x.d,y.d),min(x.r,y.r),min(x.u,y.u)};
}
main(){
IOS;
cin>>n>>p;
REP(i,0,n){
int l,d,r,u;cin>>l>>d>>r>>u;
a.pb(nd{l,d,r,u});
}
while(1){
vis.reset();
REP(k,0,p){
nd un=nd{1,1,1000000000,1000000000};
REP(i,0,n){
if(vis[i])continue;
nd tt=merge(un,a[i]);
if(tt.d<=tt.u&&tt.l<=tt.r){
vis[i]=1;
un=tt;
}
}
res[k]={un.l,un.d};
}
iota(pm,pm+n,0);
shuffle(pm,pm+n,rd);
b.clear();
REP(i,0,n){
if(!vis[pm[i]]){
b.pb(a[pm[i]]);
}
}
if(b.empty()){
REP(i,0,p)cout<<res[i].f<<" "<<res[i].s<<endl;
return 0;
}
REP(i,0,n){
if(vis[pm[i]]){
b.pb(a[pm[i]]);
}
}
a=b;
}
}
Compilation message
hamburg.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
26 | main(){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
4 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
4 ms |
512 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
3 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
4 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
4 ms |
544 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
3 ms |
512 KB |
Output is correct |
28 |
Correct |
5 ms |
512 KB |
Output is correct |
29 |
Correct |
4 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
11 ms |
512 KB |
Output is correct |
32 |
Correct |
5 ms |
512 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
6 ms |
512 KB |
Output is correct |
35 |
Correct |
3 ms |
512 KB |
Output is correct |
36 |
Correct |
4 ms |
512 KB |
Output is correct |
37 |
Correct |
3 ms |
512 KB |
Output is correct |
38 |
Correct |
2 ms |
512 KB |
Output is correct |
39 |
Correct |
2 ms |
512 KB |
Output is correct |
40 |
Correct |
5 ms |
512 KB |
Output is correct |
41 |
Correct |
4 ms |
416 KB |
Output is correct |
42 |
Correct |
5 ms |
512 KB |
Output is correct |
43 |
Correct |
4 ms |
512 KB |
Output is correct |
44 |
Correct |
3 ms |
416 KB |
Output is correct |
45 |
Correct |
3 ms |
512 KB |
Output is correct |
46 |
Correct |
2 ms |
512 KB |
Output is correct |
47 |
Correct |
3 ms |
512 KB |
Output is correct |
48 |
Correct |
3 ms |
512 KB |
Output is correct |
49 |
Correct |
2 ms |
512 KB |
Output is correct |
50 |
Correct |
2 ms |
512 KB |
Output is correct |
51 |
Correct |
2 ms |
512 KB |
Output is correct |
52 |
Correct |
11 ms |
512 KB |
Output is correct |
53 |
Correct |
3 ms |
512 KB |
Output is correct |
54 |
Correct |
2 ms |
512 KB |
Output is correct |
55 |
Correct |
2 ms |
512 KB |
Output is correct |
56 |
Correct |
2 ms |
512 KB |
Output is correct |
57 |
Correct |
2 ms |
512 KB |
Output is correct |
58 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
99 ms |
4584 KB |
Output is correct |
6 |
Correct |
114 ms |
4584 KB |
Output is correct |
7 |
Correct |
100 ms |
4584 KB |
Output is correct |
8 |
Correct |
142 ms |
4580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
118 ms |
10460 KB |
Output is correct |
6 |
Correct |
120 ms |
10464 KB |
Output is correct |
7 |
Correct |
125 ms |
10464 KB |
Output is correct |
8 |
Correct |
118 ms |
10468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
217 ms |
10464 KB |
Output is correct |
14 |
Correct |
162 ms |
10480 KB |
Output is correct |
15 |
Correct |
165 ms |
10536 KB |
Output is correct |
16 |
Correct |
140 ms |
10464 KB |
Output is correct |
17 |
Correct |
122 ms |
10464 KB |
Output is correct |
18 |
Correct |
154 ms |
10632 KB |
Output is correct |
19 |
Correct |
133 ms |
10472 KB |
Output is correct |
20 |
Correct |
246 ms |
10464 KB |
Output is correct |
21 |
Correct |
129 ms |
10420 KB |
Output is correct |
22 |
Correct |
250 ms |
10468 KB |
Output is correct |
23 |
Correct |
400 ms |
10592 KB |
Output is correct |
24 |
Correct |
208 ms |
10492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
4 ms |
512 KB |
Output is correct |
12 |
Correct |
3 ms |
512 KB |
Output is correct |
13 |
Correct |
2 ms |
512 KB |
Output is correct |
14 |
Correct |
4 ms |
512 KB |
Output is correct |
15 |
Correct |
3 ms |
512 KB |
Output is correct |
16 |
Correct |
5 ms |
512 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
4 ms |
512 KB |
Output is correct |
19 |
Correct |
3 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
4 ms |
512 KB |
Output is correct |
22 |
Correct |
2 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
5 ms |
512 KB |
Output is correct |
25 |
Correct |
4 ms |
544 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
3 ms |
512 KB |
Output is correct |
28 |
Correct |
5 ms |
512 KB |
Output is correct |
29 |
Correct |
4 ms |
512 KB |
Output is correct |
30 |
Correct |
2 ms |
512 KB |
Output is correct |
31 |
Correct |
11 ms |
512 KB |
Output is correct |
32 |
Correct |
5 ms |
512 KB |
Output is correct |
33 |
Correct |
3 ms |
512 KB |
Output is correct |
34 |
Correct |
6 ms |
512 KB |
Output is correct |
35 |
Correct |
3 ms |
512 KB |
Output is correct |
36 |
Correct |
4 ms |
512 KB |
Output is correct |
37 |
Correct |
3 ms |
512 KB |
Output is correct |
38 |
Correct |
2 ms |
512 KB |
Output is correct |
39 |
Correct |
2 ms |
512 KB |
Output is correct |
40 |
Correct |
5 ms |
512 KB |
Output is correct |
41 |
Correct |
4 ms |
416 KB |
Output is correct |
42 |
Correct |
5 ms |
512 KB |
Output is correct |
43 |
Correct |
4 ms |
512 KB |
Output is correct |
44 |
Correct |
3 ms |
416 KB |
Output is correct |
45 |
Correct |
3 ms |
512 KB |
Output is correct |
46 |
Correct |
2 ms |
512 KB |
Output is correct |
47 |
Correct |
3 ms |
512 KB |
Output is correct |
48 |
Correct |
3 ms |
512 KB |
Output is correct |
49 |
Correct |
2 ms |
512 KB |
Output is correct |
50 |
Correct |
2 ms |
512 KB |
Output is correct |
51 |
Correct |
2 ms |
512 KB |
Output is correct |
52 |
Correct |
11 ms |
512 KB |
Output is correct |
53 |
Correct |
3 ms |
512 KB |
Output is correct |
54 |
Correct |
2 ms |
512 KB |
Output is correct |
55 |
Correct |
2 ms |
512 KB |
Output is correct |
56 |
Correct |
2 ms |
512 KB |
Output is correct |
57 |
Correct |
2 ms |
512 KB |
Output is correct |
58 |
Correct |
2 ms |
512 KB |
Output is correct |
59 |
Correct |
174 ms |
10464 KB |
Output is correct |
60 |
Correct |
134 ms |
10464 KB |
Output is correct |
61 |
Correct |
126 ms |
10464 KB |
Output is correct |
62 |
Correct |
122 ms |
10460 KB |
Output is correct |
63 |
Correct |
482 ms |
10400 KB |
Output is correct |
64 |
Correct |
124 ms |
10468 KB |
Output is correct |
65 |
Correct |
399 ms |
10424 KB |
Output is correct |
66 |
Correct |
260 ms |
10464 KB |
Output is correct |
67 |
Correct |
261 ms |
10464 KB |
Output is correct |
68 |
Correct |
268 ms |
10428 KB |
Output is correct |
69 |
Correct |
619 ms |
10460 KB |
Output is correct |
70 |
Correct |
559 ms |
10432 KB |
Output is correct |
71 |
Correct |
574 ms |
10464 KB |
Output is correct |
72 |
Correct |
765 ms |
10424 KB |
Output is correct |
73 |
Correct |
752 ms |
10452 KB |
Output is correct |
74 |
Correct |
422 ms |
10412 KB |
Output is correct |
75 |
Correct |
817 ms |
10464 KB |
Output is correct |
76 |
Correct |
343 ms |
10476 KB |
Output is correct |
77 |
Correct |
850 ms |
10516 KB |
Output is correct |
78 |
Correct |
371 ms |
10448 KB |
Output is correct |
79 |
Correct |
513 ms |
10416 KB |
Output is correct |
80 |
Correct |
598 ms |
10596 KB |
Output is correct |
81 |
Correct |
806 ms |
10468 KB |
Output is correct |
82 |
Correct |
307 ms |
10432 KB |
Output is correct |
83 |
Correct |
659 ms |
10412 KB |
Output is correct |
84 |
Correct |
129 ms |
10464 KB |
Output is correct |
85 |
Correct |
597 ms |
10484 KB |
Output is correct |
86 |
Correct |
1459 ms |
10468 KB |
Output is correct |
87 |
Correct |
302 ms |
10476 KB |
Output is correct |
88 |
Correct |
852 ms |
10468 KB |
Output is correct |
89 |
Correct |
1930 ms |
10576 KB |
Output is correct |
90 |
Correct |
391 ms |
10380 KB |
Output is correct |
91 |
Correct |
217 ms |
10592 KB |
Output is correct |
92 |
Correct |
313 ms |
10592 KB |
Output is correct |
93 |
Correct |
141 ms |
10468 KB |
Output is correct |
94 |
Correct |
142 ms |
10520 KB |
Output is correct |
95 |
Correct |
466 ms |
10420 KB |
Output is correct |
96 |
Correct |
781 ms |
10444 KB |
Output is correct |
97 |
Correct |
129 ms |
10464 KB |
Output is correct |
98 |
Correct |
913 ms |
10468 KB |
Output is correct |
99 |
Correct |
773 ms |
10468 KB |
Output is correct |
100 |
Correct |
341 ms |
10436 KB |
Output is correct |
101 |
Correct |
152 ms |
10496 KB |
Output is correct |
102 |
Correct |
333 ms |
10460 KB |
Output is correct |
103 |
Correct |
145 ms |
10460 KB |
Output is correct |
104 |
Correct |
222 ms |
10456 KB |
Output is correct |
105 |
Correct |
329 ms |
10592 KB |
Output is correct |
106 |
Correct |
162 ms |
10500 KB |
Output is correct |
107 |
Correct |
452 ms |
10436 KB |
Output is correct |
108 |
Correct |
222 ms |
10444 KB |
Output is correct |
109 |
Correct |
243 ms |
10464 KB |
Output is correct |
110 |
Correct |
196 ms |
10404 KB |
Output is correct |
111 |
Correct |
871 ms |
10408 KB |
Output is correct |
112 |
Correct |
468 ms |
10464 KB |
Output is correct |
113 |
Correct |
130 ms |
10484 KB |
Output is correct |
114 |
Correct |
146 ms |
10464 KB |
Output is correct |
115 |
Correct |
141 ms |
10464 KB |
Output is correct |
116 |
Correct |
359 ms |
10464 KB |
Output is correct |
117 |
Execution timed out |
3060 ms |
10396 KB |
Time limit exceeded |
118 |
Halted |
0 ms |
0 KB |
- |