結果

問題 No.2354 Poor Sight in Winter
ユーザー hiro71687khiro71687k
提出日時 2023-06-16 22:08:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 623 ms / 2,000 ms
コード長 1,367 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 205,736 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 20:05:11
合計ジャッジ時間 7,054 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 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,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 159 ms
4,380 KB
testcase_12 AC 142 ms
4,380 KB
testcase_13 AC 623 ms
4,380 KB
testcase_14 AC 502 ms
4,380 KB
testcase_15 AC 351 ms
4,380 KB
testcase_16 AC 421 ms
4,380 KB
testcase_17 AC 437 ms
4,384 KB
testcase_18 AC 127 ms
4,380 KB
testcase_19 AC 334 ms
4,384 KB
testcase_20 AC 161 ms
4,380 KB
testcase_21 AC 7 ms
4,384 KB
testcase_22 AC 62 ms
4,384 KB
testcase_23 AC 63 ms
4,384 KB
testcase_24 AC 213 ms
4,384 KB
testcase_25 AC 39 ms
4,384 KB
testcase_26 AC 25 ms
4,384 KB
testcase_27 AC 3 ms
4,384 KB
testcase_28 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=200000000000000;
ll mod=998244353;
int main(){
    ll n,k;
    cin >> n >> k;
    ll sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    vector<ll>x(n),y(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    x.push_back(sx);
    x.push_back(gx);
    y.push_back(sy);
    y.push_back(gy);
    ll left=0,right=inf;
    while (right-left>1)
    {
        ll mid=(right+left)/2;
        queue<ll>que;
        que.push(n);
        vector<ll>memo(n+2,inf);
        memo[n]=0;
        while (!que.empty())
        {
            ll v=que.front();
            que.pop();
            for (ll i = 0; i < n+2; i++)
            {
                ll z=(abs(x[v]-x[i])+abs(y[v]-y[i]));
                if (z==0)
                {
                    continue;
                }
                ll zz=z/(mid);
                zz--;
                if (z%(mid)!=0)
                {
                    zz++;
                }
                if (memo[i]>memo[v]+zz)
                {
                    memo[i]=memo[v]+zz;
                    que.push(i);
                }
            }
        }
        if (memo[n+1]>k)
        {
            left=mid;
        }else{
            right=mid;
        }
    }
    cout << right << endl;
}
0