#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)return;
for(int i=1;i<=n;i++){
cin>>a[i].F>>a[i].S;
}
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<<" "<<v1<<endl;
cout<<suf[i+1].F<<" "<<suf[i+1].S<<" "<<v2<<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:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
57 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
336 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |