답안 #518693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518693 2022-01-24T12:36:08 Z A_D Izvanzemaljci (COI21_izvanzemaljci) C++14
0 / 100
1 ms 468 KB
#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];
ii s;
ii e;
bool com(ii a,ii b)
{
    int v=max(a.F-s.F,a.S-s.S);
    int v2=max(b.F-s.F,b.S-s.S);
    return v<v2;
}
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);
    s=a[1];
    e=a[n];
    sort(a+1,a+n+1,com);
    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:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   70 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 444 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 448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -