Submission #518694

# Submission time Handle Problem Language Result Execution time Memory
518694 2022-01-24T12:40:15 Z A_D Izvanzemaljci (COI21_izvanzemaljci) C++14
0 / 100
1 ms 460 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=3e9;
            suf[i].F=suf[i].S=3e9;
        }
    }
    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));
    }
    suf[n+1].F=3e9;
    suf[n+1].S=3e9;
    for(int i=n;i>=1;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:72:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   72 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -