結果
問題 | No.2354 Poor Sight in Winter |
ユーザー |
![]() |
提出日時 | 2023-06-16 22:08:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 636 ms / 2,000 ms |
コード長 | 1,367 bytes |
コンパイル時間 | 2,296 ms |
コンパイル使用メモリ | 201,624 KB |
最終ジャッジ日時 | 2025-02-14 05:55:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=200000000000000; ll mod=998244353; int main(){ ll n,k; cin >> n >> k; ll sx,sy,gx,gy; cin >> sx >> sy >> gx >> gy; vector<ll>x(n),y(n); for (ll i = 0; i < n; i++) { cin >> x[i] >> y[i]; } x.push_back(sx); x.push_back(gx); y.push_back(sy); y.push_back(gy); ll left=0,right=inf; while (right-left>1) { ll mid=(right+left)/2; queue<ll>que; que.push(n); vector<ll>memo(n+2,inf); memo[n]=0; while (!que.empty()) { ll v=que.front(); que.pop(); for (ll i = 0; i < n+2; i++) { ll z=(abs(x[v]-x[i])+abs(y[v]-y[i])); if (z==0) { continue; } ll zz=z/(mid); zz--; if (z%(mid)!=0) { zz++; } if (memo[i]>memo[v]+zz) { memo[i]=memo[v]+zz; que.push(i); } } } if (memo[n+1]>k) { left=mid; }else{ right=mid; } } cout << right << endl; }