結果

問題 No.2354 Poor Sight in Winter
ユーザー ぷらぷら
提出日時 2023-06-16 21:51:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,283 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 206,208 KB
実行使用メモリ 269,660 KB
最終ジャッジ日時 2023-09-06 19:23:11
合計ジャッジ時間 5,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 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;

int inf = 1001001001;

bool chmin(int &x,int y) {
    if(x > y) {
        x = y;
        return true;
    }
    return false;
}

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;
    int l = 0,r = 1001001;
    while(l+1 < r) {
        int mid = (l+r)/2;
        vector<int>dist(N+2,inf);
        dist[N] = 0;
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>que;
        que.push({0,N});
        while(!que.empty()) {
            pair<int,int>a = que.top();
            que.pop();
            if(dist[a.second] != a.first) continue;
            for(int i = 0; i < N+2; i++) {
                int nxt = abs(x[a.second]-x[i])+abs(y[a.second]-y[i]);
                nxt = (nxt-1)/mid+a.first;
                if(chmin(dist[i],nxt)) {
                    que.push({nxt,i});
                }
            }
        }
        if(dist[N+1] <= K) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << "\n";
}
0