結果

問題 No.2354 Poor Sight in Winter
ユーザー hourenhouren
提出日時 2023-06-16 22:47:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,413 bytes
コンパイル時間 1,709 ms
コンパイル使用メモリ 176,156 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 21:22:23
合計ジャッジ時間 5,299 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]);
    vector<vector<int>> di(n+2,vector<int>(n+2,0));
    rep(i,n+2)rep(j,i) di[i][j] = di[j][i] = abs(x[i]-x[j])+abs(y[i]-y[j]);
    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();
            if(now==1) break;
            pq.pop();
            if(dist[now]!=d) continue;
            rep(i,n+2){
                if(chmin(dist[i], dist[now]+(di[now][i]-1)/md)) pq.push({dist[i],i});
            }
        }
        if(dist[1]<=k) ok = md;
        else ng = md;
    }
    cout << ok << '\n';
    return 0;
}
0