#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
typedef vector<int> vi;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
int n,k;
vector<ii> all;
map<int,vector<int> > row,col;
vector<int> find_one_square(vector<ii> v){
if(SZ(v)==0)return {0,0,1};
int minx=LLINF,maxx=-LLINF,miny=LLINF,maxy=-LLINF;
for(ii i:v){
minx=min(minx,i.fi);
maxx=max(maxx,i.fi);
miny=min(miny,i.se);
maxy=max(maxy,i.se);
}
int l=max(1LL,max(maxx-minx,maxy-miny));
return {minx,miny,l};
}
bool disjoint(vector<int> v1,vector<int> v2){
return (v1[0]+v1[2]<v2[0])||(v2[0]+v2[2]<v1[0])||(v1[1]+v1[2]<v2[1])||(v2[1]+v2[2]<v1[1]);
}
int32_t main(){
scanf("%lld%lld",&n,&k);
int x,y;
for(int i=0;i<n;i++){
scanf("%lld%lld",&x,&y);
all.pb(x,y);
row[y].pb(x);
col[x].pb(y);
}
if(k==1){
vector<int> ans=find_one_square(all);
printf("%lld %lld %lld\n",ans[0],ans[1],ans[2]);
}else if(k==2){
int le=3*INF;
vector<int> ans[2];
vector<ii> pre,pst;
vector<int> a1,a2;int x;
for(auto it=row.begin();it!=row.end();++it){
sort(ALL(it->se));
for(int i:it->se)pst.pb(i,it->fi);
}
reverse(ALL(pst));
for(auto it=row.begin();it!=row.end();++it){
for(int i=0;i<SZ(it->se);i++){
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
pre.pb(pst.back());
pst.pop_back();
}
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
for(int i:it->se){pst.pb(i,it->fi);pre.pop_back();}
for(int i=0;i<SZ(it->se);i++){
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
pre.pb(pst.back());
pst.pop_back();
}
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
}
pre.clear();pst.clear();
for(auto it=col.begin();it!=col.end();++it){
sort(ALL(it->se));
for(int i:it->se)pst.pb(it->fi,i);
}
reverse(ALL(pst));
for(auto it=col.begin();it!=col.end();++it){
for(int i=0;i<SZ(it->se);i++){
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
pre.pb(pst.back());
pst.pop_back();
}
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
for(int i:it->se){pst.pb(it->fi,i);pre.pop_back();}
for(int i=0;i<SZ(it->se);i++){
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
pre.pb(pst.back());
pst.pop_back();
}
a1=find_one_square(pre);a2=find_one_square(pst);
x=max(a1[2],a2[2]);
if(x<le&&disjoint(a1,a2)){le=x;ans[0]=a1;ans[1]=a2;}
}
for(int i=0;i<2;i++){for(int j=0;j<3;j++)printf("%lld ",ans[i][j]);printf("\n");}
}else{
}
}
/*
5 2
1 3
3 1
5 5
5 10
7 7
*/
Compilation message
izvanzemaljci.cpp: In function 'int32_t main()':
izvanzemaljci.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | scanf("%lld%lld",&n,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~
izvanzemaljci.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%lld%lld",&x,&y);
| ~~~~~^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
164 ms |
25300 KB |
Output is correct |
8 |
Correct |
190 ms |
25400 KB |
Output is correct |
9 |
Correct |
171 ms |
25216 KB |
Output is correct |
10 |
Correct |
163 ms |
25228 KB |
Output is correct |
11 |
Correct |
180 ms |
25260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |