結果

問題 No.2354 Poor Sight in Winter
ユーザー tsugutsugutsugutsugu
提出日時 2023-06-17 02:13:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,494 bytes
コンパイル時間 3,013 ms
コンパイル使用メモリ 251,128 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 01:16:03
合計ジャッジ時間 4,728 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 26 ms
4,380 KB
testcase_13 AC 40 ms
4,384 KB
testcase_14 AC 37 ms
4,380 KB
testcase_15 AC 31 ms
4,384 KB
testcase_16 AC 33 ms
4,384 KB
testcase_17 AC 36 ms
4,384 KB
testcase_18 AC 13 ms
4,384 KB
testcase_19 AC 27 ms
4,380 KB
testcase_20 AC 15 ms
4,384 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 8 ms
4,380 KB
testcase_23 AC 9 ms
4,384 KB
testcase_24 AC 20 ms
4,380 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 5 ms
4,384 KB
testcase_27 AC 2 ms
4,384 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 1
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    vector<int> x(n + 2), y(n + 2);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
    }
    x[n] = sx, y[n] = sy;
    x[n + 1] = gx, y[n + 1] = gy;
    auto check = [&] (int p) -> bool {
        const int inf = 1 << 30;
        vector<int> dist(n + 2, inf);
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
        Q.emplace(0, n);
        dist[n] = 0;
        while (!Q.empty()) {
            auto P = Q.top();
            Q.pop();
            int pos = P.second;
            int d = P.first;
            if (dist[pos] < d) {
                continue;
            }
            for (int i = 0; i < n + 2; i++) {
                int m = abs(x[pos] - x[i]) + abs(y[pos] - y[i]);
                int ndis = dist[pos] + max(0, (m + p - 1) / p - 1);
                if (ndis < dist[i]) {
                    dist[i] = ndis;
                    Q.emplace(ndis, i);
                }
            }
        }
        return dist[n + 1] <= k;
    };
    int ok = 200005, ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) >> 1;
        if (check(mid)) {
            ok = mid; 
        } else {
            ng = mid;
        }
    }
    cout << ok << '\n';
}
0