#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;
nd a[maxn];
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)cin>>a[i].l>>a[i].d>>a[i].r>>a[i].u;
while(1){
shuffle(a,a+n,rd);
vis.reset();
int c=0;
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){
++c;
vis[i]=1;
un=tt;
}
}
res[k]={un.l,un.d};
}
if(c==n){
REP(i,0,p)cout<<res[i].f<<" "<<res[i].s<<endl;
return 0;
}
}
}
Compilation message
hamburg.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
26 | main(){
| ^
# |
Verdict |
Execution time |
Memory |
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 |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
456 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 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 |
91 ms |
384 KB |
Output is correct |
9 |
Correct |
15 ms |
384 KB |
Output is correct |
10 |
Correct |
42 ms |
384 KB |
Output is correct |
11 |
Correct |
18 ms |
452 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
8 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
38 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
91 ms |
448 KB |
Output is correct |
8 |
Correct |
32 ms |
384 KB |
Output is correct |
9 |
Correct |
192 ms |
448 KB |
Output is correct |
10 |
Correct |
364 ms |
384 KB |
Output is correct |
11 |
Correct |
114 ms |
452 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
860 ms |
444 KB |
Output is correct |
14 |
Correct |
559 ms |
452 KB |
Output is correct |
15 |
Correct |
127 ms |
448 KB |
Output is correct |
16 |
Correct |
659 ms |
448 KB |
Output is correct |
17 |
Correct |
223 ms |
456 KB |
Output is correct |
18 |
Correct |
94 ms |
452 KB |
Output is correct |
19 |
Correct |
45 ms |
444 KB |
Output is correct |
20 |
Execution timed out |
3081 ms |
384 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
440 KB |
Output is correct |
5 |
Correct |
100 ms |
3448 KB |
Output is correct |
6 |
Correct |
136 ms |
3448 KB |
Output is correct |
7 |
Correct |
120 ms |
3448 KB |
Output is correct |
8 |
Correct |
98 ms |
3600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
10 ms |
456 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
1648 ms |
3448 KB |
Output is correct |
6 |
Execution timed out |
3065 ms |
3448 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 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 |
91 ms |
384 KB |
Output is correct |
9 |
Correct |
15 ms |
384 KB |
Output is correct |
10 |
Correct |
42 ms |
384 KB |
Output is correct |
11 |
Correct |
18 ms |
452 KB |
Output is correct |
12 |
Correct |
20 ms |
384 KB |
Output is correct |
13 |
Correct |
783 ms |
3548 KB |
Output is correct |
14 |
Correct |
1962 ms |
3452 KB |
Output is correct |
15 |
Execution timed out |
3058 ms |
3484 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
8 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
38 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
91 ms |
448 KB |
Output is correct |
8 |
Correct |
32 ms |
384 KB |
Output is correct |
9 |
Correct |
192 ms |
448 KB |
Output is correct |
10 |
Correct |
364 ms |
384 KB |
Output is correct |
11 |
Correct |
114 ms |
452 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
860 ms |
444 KB |
Output is correct |
14 |
Correct |
559 ms |
452 KB |
Output is correct |
15 |
Correct |
127 ms |
448 KB |
Output is correct |
16 |
Correct |
659 ms |
448 KB |
Output is correct |
17 |
Correct |
223 ms |
456 KB |
Output is correct |
18 |
Correct |
94 ms |
452 KB |
Output is correct |
19 |
Correct |
45 ms |
444 KB |
Output is correct |
20 |
Execution timed out |
3081 ms |
384 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |