結果
問題 | No.2612 Close the Distance |
ユーザー | 蜜蜂 |
提出日時 | 2023-06-15 19:38:08 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 632 ms / 3,000 ms |
コード長 | 2,356 bytes |
コンパイル時間 | 3,904 ms |
コンパイル使用メモリ | 233,348 KB |
実行使用メモリ | 22,044 KB |
最終ジャッジ日時 | 2024-01-20 00:17:31 |
合計ジャッジ時間 | 15,436 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,548 KB |
testcase_01 | AC | 2 ms
6,548 KB |
testcase_02 | AC | 2 ms
6,548 KB |
testcase_03 | AC | 2 ms
6,548 KB |
testcase_04 | AC | 2 ms
6,548 KB |
testcase_05 | AC | 2 ms
6,548 KB |
testcase_06 | AC | 386 ms
17,120 KB |
testcase_07 | AC | 357 ms
16,804 KB |
testcase_08 | AC | 390 ms
17,056 KB |
testcase_09 | AC | 374 ms
16,672 KB |
testcase_10 | AC | 369 ms
17,312 KB |
testcase_11 | AC | 375 ms
17,056 KB |
testcase_12 | AC | 377 ms
17,568 KB |
testcase_13 | AC | 380 ms
17,568 KB |
testcase_14 | AC | 382 ms
16,544 KB |
testcase_15 | AC | 389 ms
17,120 KB |
testcase_16 | AC | 612 ms
20,364 KB |
testcase_17 | AC | 588 ms
20,364 KB |
testcase_18 | AC | 632 ms
21,260 KB |
testcase_19 | AC | 602 ms
21,396 KB |
testcase_20 | AC | 604 ms
20,364 KB |
testcase_21 | AC | 599 ms
22,044 KB |
testcase_22 | AC | 622 ms
22,044 KB |
testcase_23 | AC | 605 ms
19,224 KB |
testcase_24 | AC | 610 ms
20,364 KB |
testcase_25 | AC | 602 ms
21,140 KB |
testcase_26 | AC | 2 ms
6,548 KB |
コンパイルメッセージ
main.cpp: In function 'bool sub(std::vector<std::pair<long long int, long long int> >&, int)': main.cpp:36:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 36 | for(auto [w,v]:p){ | ^ main.cpp:45:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 45 | for(auto [w,v]:p){ | ^ main.cpp: In function 'int main()': main.cpp:86:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 86 | for(auto [w,v]:p){ | ^
ソースコード
//g++ 1.cpp -std=c++17 -O2 -I . #include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using ld = long double; using vi = vector<int>; using vvi = vector<vi>; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; using vvld = vector<vld>; using vst = vector<string>; using vvst = vector<vst>; #define fi first #define se second #define pb push_back #define eb emplace_back #define pq_big(T) priority_queue<T,vector<T>,less<T>> #define pq_small(T) priority_queue<T,vector<T>,greater<T>> #define all(a) a.begin(),a.end() #define rep(i,start,end) for(ll i=start;i<(ll)(end);i++) #define per(i,start,end) for(ll i=start;i>=(ll)(end);i--) #define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end()) bool sub(vector<pair<ll,ll>> &p,int a){ int n=p.size(); ll min_w=1e18,max_w=-1e18; ll min_v=1e18,max_v=-1e18; for(auto [w,v]:p){ min_w=min(min_w,w); max_w=max(max_w,w); min_v=min(min_v,v); max_v=max(max_v,v); } bool flg=0,flg2=1,flg3=1,flg4,flg5; for(auto [w,v]:p){ flg4=0,flg5=0; if(abs(min_w-w)<=a&&abs(min_v-v)<=a)flg4=1; if(abs(max_w-w)<=a&&abs(max_v-v)<=a)flg4=1; if(abs(min_w-w)<=a&&abs(max_v-v)<=a)flg5=1; if(abs(max_w-w)<=a&&abs(min_v-v)<=a)flg5=1; flg2=min(flg2,flg4); flg3=min(flg3,flg5); } flg=max({flg,flg2,flg3}); return flg; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n;cin>>n; ll min_w=1e18,max_w=-1e18; ll min_v=1e18,max_v=-1e18; vector<pair<ll,ll>> p(n); rep(i,0,n){ ll x,y;cin>>x>>y; ll w=x+y,v=x-y; p[i]={w,v}; min_w=min(min_w,w); max_w=max(max_w,w); min_v=min(min_v,v); max_v=max(max_v,v); } ll ng=-1,ok=1e18; while(ok-ng>1){ ll check=(ok+ng)/2; int flg=0; vector<pair<ll,ll>> p1,p2,p3,p4; for(auto [w,v]:p){ if(abs(min_w-w)>check||abs(min_v-v)>check)p1.emplace_back(w,v); if(abs(min_w-w)>check||abs(max_v-v)>check)p2.emplace_back(w,v); if(abs(max_w-w)>check||abs(min_v-v)>check)p3.emplace_back(w,v); if(abs(max_w-w)>check||abs(max_v-v)>check)p4.emplace_back(w,v); } flg=max({flg,(int)sub(p1,check),(int)sub(p2,check),(int)sub(p3,check),(int)sub(p4,check)}); if(flg){ ok=check; } else{ ng=check; } } cout<<ok<<endl; }