結果
問題 | No.2354 Poor Sight in Winter |
ユーザー | snrnsidy |
提出日時 | 2023-06-16 22:40:36 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 3,728 bytes |
コンパイル時間 | 3,222 ms |
コンパイル使用メモリ | 361,204 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 15:24:57 |
合計ジャッジ時間 | 5,254 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#pragma GCC optimize("O3") #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; long long int dp[501]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n,k; int sx,sy,gx,gy; int x,y; vector <pair<int,int>> v; cin >> n >> k; cin >> sx >> sy >> gx >> gy; v.push_back(make_pair(sx,sy)); for(int i=0;i<n;i++) { cin >> x >> y; v.push_back(make_pair(x,y)); } v.push_back(make_pair(gx,gy)); n = v.size(); int lo = 1; int hi = 1e9; int res = 1e9; while(lo<=hi) { int mid = (lo + hi)/2; fill(dp,dp+n,1e18); dp[0] = 0; priority_queue <pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pque; pque.push(make_pair(dp[0],0)); while(!pque.empty()) { int now = pque.top().second; if(dp[now] < pque.top().first) { pque.pop(); continue; } pque.pop(); for(int next=0;next<n;next++) { if(now==next) continue; long long int dx = abs(v[now].first - v[next].first); long long int dy = abs(v[next].second - v[now].second); long long int D = dx + dy; long long int cost = D/mid; if(D%mid!=0) cost += 1; cost -= 1; if(dp[next] > dp[now] + cost) { dp[next] = dp[now] + cost; pque.push(make_pair(dp[next],next)); } } } if(dp[n-1] <= k) { res = min(res,mid); hi = mid - 1; } else { lo = mid + 1; } } cout << res << '\n'; return 0; }