結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-16 22:05:58 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 7,212 ms |
| コンパイル使用メモリ | 263,260 KB |
| 最終ジャッジ日時 | 2025-02-14 05:50:06 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 3 |
| other | TLE * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main () {
int N, K;
cin >> N >> K;
int X[555], Y[555];
for (int i = 0; i < N + 2; i ++) {
cin >> X[i + 1] >> Y[i + 1];
}
int ok = 2e5 + 5, ng = 0;
using P = pair<int, int>;
while (abs(ok - ng) > 0) {
int mu = (ok + ng) / 2;
vector<int> D(N + 2, 1e9 + 7);
D[0] = 0;
priority_queue<P, vector<P>, greater<P>> pque;
pque.emplace(0, 0);
while (!pque.empty()) {
auto [l, u] = pque.top();
pque.pop();
if (l != D[u]) continue;
for (int v = 1; v < N + 2; v ++) {
int d = abs(X[v] - X[u]) + abs(Y[v] - Y[u]);
d = (d + mu - 1) / mu;
if (l + d < D[v]) {
D[v] = l + d;
pque.emplace(D[v], v);
}
}
}
if (D[1] <= K) {
ok = mu;
} else {
ng = mu;
}
}
cout << ok << endl;
}