結果

問題 No.2354 Poor Sight in Winter
ユーザー 👑 NachiaNachia
提出日時 2023-06-16 22:30:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,313 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 85,676 KB
実行使用メモリ 7,352 KB
最終ジャッジ日時 2023-09-06 20:46:00
合計ジャッジ時間 2,694 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 46 ms
7,152 KB
testcase_12 AC 38 ms
7,152 KB
testcase_13 AC 72 ms
7,264 KB
testcase_14 AC 76 ms
7,080 KB
testcase_15 AC 68 ms
7,100 KB
testcase_16 AC 73 ms
7,352 KB
testcase_17 AC 78 ms
7,148 KB
testcase_18 AC 22 ms
4,376 KB
testcase_19 AC 48 ms
5,640 KB
testcase_20 AC 25 ms
4,580 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 12 ms
4,376 KB
testcase_24 AC 41 ms
5,208 KB
testcase_25 AC 8 ms
4,376 KB
testcase_26 AC 7 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;

int main(){
    int N; cin >> N; N+=2;
    int M; cin >> M;
    vector<i64> X(N), Y(N);
    rep(i,N) cin >> X[i] >> Y[i];
    vector<vector<i64>> dist(N, vector<i64>(N));
    rep(i,N) rep(j,N) dist[i][j] = abs(X[i]-X[j]) + abs(Y[i]-Y[j]);
    int ng = 0, ok = dist[0][1];
    while(abs(ng - ok) > 1){
        i64 K = (ng + ok) / 2;
        auto d = dist;
        for(auto& dd : d) for(auto& e : dd) e = max<i64>((e + K - 1) / K - 1, 0);
        vector<i64> ds(N, INF);
        ds[0] = 0;
        vector<int> vis(N, 0);
        rep(i,N){
            int x = -1;
            rep(j,N) if(vis[j] == 0) if(x < 0 || ds[x] > ds[j]) x = j;
            rep(j,N) ds[j] = min(ds[j], ds[x] + d[x][j]);
            vis[x] = 1;
        }
        (ds[1] <= M ? ok : ng) = K;
    }
    cout << ok << endl;
    return 0;
}



struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0