#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define F first
#define S second
using namespace std;
const int N=1e5+100;
ii a[N];
ii pre[N];
ii pre2[N];
ii suf[N];
ii suf2[N];
void solve()
{
int n,k;
cin>>n>>k;
if(k!=2)assert(0);
for(int i=1;i<=n;i++){
cin>>a[i].F>>a[i].S;
}
if(n!=1){
for(int i=0;i<=n+1;i++){
pre[i].F=pre[i].S=1e18;
suf[i].F=suf[i].S=1e18;
}
}
sort(a+1,a+n+1);
for(int i=1;i<=n;i++){
pre[i].F=min(pre[i-1].F,a[i].F);
pre[i].S=min(pre[i-1].S,a[i].S);
pre2[i].F=max(pre2[i-1].F,a[i].F);
pre2[i].S=max(pre2[i-1].S,a[i].S);
}
for(int i=n;i>=1;i--){
suf[i].F=min(suf[i+1].F,a[i].F);
suf[i].S=min(suf[i+1].S,a[i].S);
suf2[i].F=max(suf2[i+1].F,a[i].F);
suf2[i].S=max(suf2[i+1].S,a[i].S);
}
int mn=1e18;
for(int i=1;i<=n;i++){
int v1=max(pre2[i].F-pre[i].F,pre2[i].S-pre[i].S);
int v2=max(suf2[i+1].F-suf[i+1].F,suf2[i+1].S-suf[i+1].S);
mn=min(mn,max(v1,v2));
}
for(int i=1;i<=n;i++){
int v1=max(pre2[i].F-pre[i].F,pre2[i].S-pre[i].S);
int v2=max(suf2[i+1].F-suf[i+1].F,suf2[i+1].S-suf[i+1].S);
if(max(v1,v2)==mn){
cout<<pre[i].F<<" "<<pre[i].S<<" "<<max(v1,(int)1)<<endl;
cout<<suf[i+1].F<<" "<<suf[i+1].S<<" "<<max(v2,(int)1)<<endl;
break;
}
}
}
main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
//cin>>t;
while(t--){
solve();
}
}
Compilation message
izvanzemaljci.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
59 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |