結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2023-06-16 22:42:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,278 bytes |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 176,344 KB |
| 実行使用メモリ | 273,156 KB |
| 最終ジャッジ日時 | 2024-06-24 15:28:09 |
| 合計ジャッジ時間 | 5,305 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n,k;
cin >> n >> k;
vector<int> x(n+2), y(n+2);
rep(i,n+2) cin >> x[i] >> y[i];
int ng = 0, ok = abs(x[0]-x[1]) + abs(y[0]-y[1]);
while(ok-ng>1){
int md = (ok+ng)/2;
vector<int> dist(n+2,INF);
dist[0] = 0;
priority_queue<asc(P)> pq;
pq.push({0,0});
while(pq.size()){
int now, d;
tie(d,now) = pq.top();
pq.pop();
if(dist[now]!=d) continue;
rep(i,n+2){
if(chmin(dist[i], dist[now]+(abs(x[now]-x[i])+abs(y[now]-y[i])-1)/md)) pq.push({dist[i],i});
}
}
if(dist[1]<=k) ok = md;
else ng = md;
}
cout << ok << '\n';
return 0;
}
houren