結果
問題 | No.2354 Poor Sight in Winter |
ユーザー |
![]() |
提出日時 | 2023-06-16 22:11:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 1,187 bytes |
コンパイル時間 | 4,212 ms |
コンパイル使用メモリ | 257,940 KB |
最終ジャッジ日時 | 2025-02-14 06:04:06 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>using namespace std;using namespace atcoder;typedef modint998244353 mint;typedef long long ll;int main(){int n, k; cin >> n >> k;n += 2;int sx, sy; cin >> sx >> sy;int gx, gy; cin >> gx >> gy;vector<int> x(n), y(n);for (int i=0; i<n-2; i++){cin >> x[i+1] >> y[i+1];}x[0] = sx;y[0] = sy;x[n-1] = gx;y[n-1] = gy;int ub = 300000;int lb = 0;while (ub - lb > 1){int targ = (ub + lb) / 2;vector ikeru(n, vector<pair<int,int>>(0));for (int i=0; i<n; i++){for (int j=i+1; j<n; j++){int trg = abs(x[i] - x[j]) + abs(y[i] - y[j]);int req = (trg + targ - 1) / targ - 1;ikeru[i].push_back(pair(j, req));ikeru[j].push_back(pair(i, req));}}vector<int> d(n, 1e9);priority_queue<pair<int,int>> pq;pq.push(pair(0, 0));d[0] = 0;while(!pq.empty()){auto [tmp, i] = pq.top();pq.pop();tmp = -tmp;if (tmp > d[i]) continue;for (auto [j, dist] : ikeru[i]){int res = tmp + dist;if (res < d[j]){d[j] = res;pq.push(pair(-res, j));}}}if (d[n-1] <= k){ub = targ;}else{lb = targ;}}cout << ub << endl;}