結果

問題 No.2354 Poor Sight in Winter
ユーザー iomir
提出日時 2023-06-17 19:13:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,296 bytes
コンパイル時間 1,838 ms
コンパイル使用メモリ 176,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-25 09:09:09
合計ジャッジ時間 3,254 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:40:18: warning: 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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0