結果

問題 No.2354 Poor Sight in Winter
ユーザー nemutainemutai
提出日時 2023-06-17 19:13:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,296 bytes
コンパイル時間 1,852 ms
コンパイル使用メモリ 174,780 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 15:19:40
合計ジャッジ時間 3,848 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 63 ms
4,376 KB
testcase_12 AC 63 ms
4,380 KB
testcase_13 AC 80 ms
4,376 KB
testcase_14 AC 76 ms
4,380 KB
testcase_15 AC 71 ms
4,380 KB
testcase_16 AC 73 ms
4,376 KB
testcase_17 AC 73 ms
4,380 KB
testcase_18 AC 26 ms
4,380 KB
testcase_19 AC 52 ms
4,376 KB
testcase_20 AC 31 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 16 ms
4,376 KB
testcase_23 AC 16 ms
4,380 KB
testcase_24 AC 41 ms
4,376 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:40:18: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   40 |             auto [co,now]=pq.top();pq.pop();
      |                  ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;


const ll INF=1ll<<60;
ll mod10=1e9+7;
ll mod99=998244353;
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<n;++i)
#define per(i,n) for(int i=n-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=a;i<n;++i)
#define per2(i,a,n) for (ll i=a;i>=n;--i)

int main(){
    ll N,K;
    cin>>N>>K;
    ll sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    vll X(N+2),Y(N+2);
    X[0]=sx,Y[0]=sy,X[N+1]=gx,Y[N+1]=gy;
    rep(i,N)cin>>X[i+1]>>Y[i+1];

    ll l=0,r=1e6;
    while(r-l>1){
        ll m=(r+l)/2;
        priority_queue<P,vp,greater<P>> pq;
        vll dist(N+2,INF);
        dist[0]=0;
        pq.emplace(0,0);
        while(pq.size()){
            auto [co,now]=pq.top();pq.pop();
            if(dist[now]<co)continue;
            rep(to,N+2){
                ll toco=(abs(X[now]-X[to])+abs(Y[now]-Y[to])+m-1)/m-1;
                if(dist[to]<=dist[now]+toco||now==to)continue;
                dist[to]=dist[now]+toco;
                pq.emplace(dist[to],to);
            }
        }
        if(dist[N+1]<=K)r=m;
        else l=m;
    }
    cout<<r<<endl;
}
0