# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
212713 | username | 함박 스테이크 (JOI20_hamburg) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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,1e9,1e9};
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;
}
}
}