結果

問題 No.2612 Close the Distance
ユーザー RubikunRubikun
提出日時 2024-01-19 21:58:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,355 bytes
コンパイル時間 2,517 ms
コンパイル使用メモリ 214,204 KB
実行使用メモリ 30,956 KB
最終ジャッジ日時 2024-01-19 21:59:23
合計ジャッジ時間 8,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 4 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 2,675 ms
24,280 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://atcoder.jp/contests/xmascon19/tasks/xmascon19_f

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005;
const ll INF=1LL<<34;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<pair<ll,ll>> S(N);
    for(int i=0;i<N;i++){
        ll a,b;cin>>a>>b;
        S[i]=mp(a+b,a-b);
    }
    sort(all(S));
    
    auto solve=[&](vector<pair<ll,ll>> X,int type,ll len){
        if(si(X)==0) return X;
        ll miH=INF,maH=-INF,miW=INF,maW=-INF;
        for(auto [a,b]:X){
            chmin(miH,a);
            chmax(maH,a);
            chmin(miW,b);
            chmax(maW,b);
        }
        vector<pair<ll,ll>> res;
        ll U,D,L,R;
        if(type==0){
            U=miH;
            D=miH+len;
            L=miW;
            R=miW+len;
        }
        if(type==1){
            U=miH;
            D=miH+len;
            L=maW-len;
            R=maW;
        }
        if(type==2){
            U=maH-len;
            D=maH;
            L=miW;
            R=miW+len;
        }
        if(type==3){
            U=maH-len;
            D=maH;
            L=maW-len;
            R=maW;
        }
        for(auto [a,b]:X){
            if(U<=a&&a<=D&&L<=b&&b<=R){
                
            }else{
                res.push_back(mp(a,b));
            }
        }
        return res;
    };
    
    ll left=-1,right=1LL<<33;
    while(right-left>1){
        ll mid=(left+right)/2;
        bool f=false;
        for(int a=0;a<4;a++){
            for(int b=0;b<4;b++){
                for(int c=0;c<4;c++){
                    auto T=S;
                    T=solve(T,a,mid);
                    T=solve(T,b,mid);
                    T=solve(T,c,mid);
                    if(si(T)==0) f=true;
                }
                if(f) break;
            }
            if(f) break;
        }
        if(f) right=mid;
        else left=mid;
    }
    
    cout<<right<<endl;
}

0