#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef DEBUG
#define dbg(...) printf(__VA_ARGS__);
#else
#define dbg(...)
#endif
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define INF 2023456789
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define maxn 100005
int n,k,x[maxn],y[maxn],pfxmn[maxn],pfxmx[maxn],sfxmn[maxn],sfxmx[maxn];
main(){
sf("%lld%lld",&n,&k);
if(k==1){
int mnx=INF,mny=INF,mxx=-INF,mxy=-INF;
for(int i=0;i<n;++i){
int x,y;sf("%lld%lld",&x,&y);
mnx=min(mnx,x);
mxx=max(mxx,x);
mny=min(mny,y);
mxy=max(mxy,y);
}
pf("%lld %lld %lld\n",mnx,mny,max(1ll,max(mxx-mnx,mxy-mny)));
}
if(k==2){
vector<ii> v;
for(int i=0;i<n;++i){
sf("%lld%lld",&x[i],&y[i]);
v.pb({x[i],y[i]});
}
if(v.size()==1){
pf("%lld %lld 1\n2000000000 2000000000 1\n",x[0],y[0]);
return 0;
}
int best=INF;
vi ansx,ansy,ansl;
{
sort(all(v));
pfxmn[0]=pfxmx[0]=v[0].se;
sfxmn[n-1]=sfxmx[n-1]=v[n-1].se;
for(int i=1;i<n;++i){
pfxmn[i]=min(pfxmn[i-1],v[i].se);
pfxmx[i]=max(pfxmx[i-1],v[i].se);
}
for(int i=n-2;i>=0;--i){
sfxmn[i]=min(sfxmn[i+1],v[i].se);
sfxmx[i]=max(sfxmx[i+1],v[i].se);
}
for(int i=0;i<n-1;++i){
if(v[i].fi==v[i+1].fi)continue;
int l1=max(1ll,max(v[i].fi-v[0].fi,pfxmx[i]-pfxmn[i]));
int l2=max(1ll,max(v[n-1].fi-v[i+1].fi,sfxmx[i+1]-sfxmn[i+1]));
if(max(l1,l2)<best){
best=max(l1,l2);
ansx={v[i].fi-l1,v[i+1].fi};
ansy={pfxmn[i],sfxmn[i+1]};
ansl={l1,l2};
}
}
}
{
sort(all(v),[](ii &a,ii&b){return a.se<b.se;});
pfxmn[0]=pfxmx[0]=v[0].fi;
sfxmn[n-1]=sfxmx[n-1]=v[n-1].fi;
for(int i=1;i<n;++i){
pfxmn[i]=min(pfxmn[i-1],v[i].fi);
pfxmx[i]=max(pfxmx[i-1],v[i].fi);
}
for(int i=n-2;i>=0;--i){
sfxmn[i]=min(sfxmn[i+1],v[i].fi);
sfxmx[i]=max(sfxmx[i+1],v[i].fi);
}
for(int i=0;i<n-1;++i){
if(v[i].se==v[i+1].se)continue;
int l1=max(1ll,max(v[i].se-v[0].se,pfxmx[i]-pfxmn[i]));
int l2=max(1ll,max(v[n-1].se-v[i+1].se,sfxmx[i+1]-sfxmn[i+1]));
if(max(l1,l2)<best){
best=max(l1,l2);
ansx={pfxmn[i],sfxmn[i+1]};
ansy={v[i].se-l1,v[i+1].se};
ansl={l1,l2};
}
}
}
for(int i=0;i<2;++i){
pf("%lld %lld %lld\n",ansx[i],ansy[i],ansl[i]);
}
}
}
/*
4 2
1000000000 1000000000
-1000000000 -1000000000
1000000000 -1000000000
-1000000000 1000000000
*/
Compilation message
izvanzemaljci.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
27 | main(){
| ^~~~
izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:28:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | sf("%lld%lld",&n,&k);
| ^
izvanzemaljci.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | int x,y;sf("%lld%lld",&x,&y);
| ^
izvanzemaljci.cpp:43:6: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
43 | sf("%lld%lld",&x[i],&y[i]);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
26 ms |
292 KB |
Output is correct |
8 |
Correct |
21 ms |
212 KB |
Output is correct |
9 |
Correct |
22 ms |
304 KB |
Output is correct |
10 |
Correct |
22 ms |
304 KB |
Output is correct |
11 |
Correct |
27 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
50 ms |
6576 KB |
Output is correct |
11 |
Correct |
50 ms |
8688 KB |
Output is correct |
12 |
Correct |
48 ms |
8660 KB |
Output is correct |
13 |
Correct |
56 ms |
8616 KB |
Output is correct |
14 |
Correct |
45 ms |
8760 KB |
Output is correct |
15 |
Correct |
46 ms |
8632 KB |
Output is correct |
16 |
Correct |
48 ms |
8600 KB |
Output is correct |
17 |
Correct |
40 ms |
7844 KB |
Output is correct |
18 |
Correct |
51 ms |
7692 KB |
Output is correct |
19 |
Correct |
39 ms |
7060 KB |
Output is correct |
20 |
Correct |
42 ms |
7564 KB |
Output is correct |
21 |
Correct |
46 ms |
8672 KB |
Output is correct |
22 |
Correct |
49 ms |
8700 KB |
Output is correct |
23 |
Correct |
47 ms |
8616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int64 expected |
2 |
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 |
0 ms |
212 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |