結果
| 問題 |
No.2354 Poor Sight in Winter
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2023-06-16 22:14:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,549 bytes |
| コンパイル時間 | 1,977 ms |
| コンパイル使用メモリ | 195,304 KB |
| 最終ジャッジ日時 | 2025-02-14 06:08:31 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=505,INF=1<<30;
ll dis[MAX];
int X[MAX],Y[MAX];
bool kaku[MAX];
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int N;cin>>N;
int K;cin>>K;
int sx,sy,gx,gy;cin>>sx>>sy>>gx>>gy;
for(int i=1;i<=N;i++){
cin>>X[i]>>Y[i];
}
X[0]=sx;
Y[0]=sy;
X[N+1]=gx;
Y[N+1]=gy;
int left=0,right=3e5;
while(right-left>1){
int mid=(left+right)/2;
for(int i=0;i<MAX;i++){
dis[i]=INF;
kaku[i]=false;
}
dis[0]=0;
for(int t=0;t<N+2;t++){
pair<ll,int> mi=mp(INF,INF);
for(int i=0;i<N+2;i++){
if(!kaku[i]){
chmin(mi,mp(dis[i],i));
}
}
int u=mi.se;
kaku[u]=true;
for(int j=0;j<N+2;j++){
if(kaku[j]) continue;
chmin(dis[j],dis[u]+((abs(X[u]-X[j])+abs(Y[u]-Y[j])-1)/mid));
}
}
if(dis[N+1]<=K) right=mid;
else left=mid;
}
cout<<right<<endl;
}
Rubikun