結果
| 問題 |
No.1599 Hikyaku
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-04 03:45:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,278 bytes |
| コンパイル時間 | 2,039 ms |
| コンパイル使用メモリ | 205,840 KB |
| 最終ジャッジ日時 | 2025-01-21 06:38:23 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 WA * 8 |
ソースコード
#include<bits/stdc++.h>
const double eps=1.0e-9;
using namespace std;
using pi=pair<int,int>;
using pdpi=pair<double,pi>;
int main(){
int x,y;
cin >> x >> y;
x--;y--;
int rd=x*600+y;
int n;
cin >> n;
vector<int> sx(n),sy(n),sv(n);
double dp[393939][16];
for(int i=0;i<393939;i++){
for(int j=0;j<16;j++){
dp[i][j]=1.0e9;
}
}
double len[32];
for(int i=1;i<32;i++){len[i]=1000.0/((double)i);}
priority_queue<pdpi,vector<pdpi>,greater<pdpi>> pq;
for(int i=0;i<n;i++){
cin >> sx[i] >> sy[i] >> sv[i];
sx[i]--;sy[i]--;
if(i){
dp[sx[i]*600+sy[i]][sv[i]]=0.0;
pq.push({0.0,{sx[i]*600+sy[i],sv[i]}});
}
else{
dp[sx[i]*600+sy[i]][7+sv[i]]=0.0;
pq.push({0.0,{sx[i]*600+sy[i],7+sv[i]}});
}
}
while(!pq.empty()){
pdpi od=pq.top();pq.pop();
int vp=od.second.first;
int vt=od.second.second;
if(dp[vp][vt]<od.first){continue;}
//cout << od.first << ':';
//cout << vp << ' ';
//cout << vt << '\n';
if(od.second.first==rd && vt>=8){
printf("%.12lf\n",od.first);
return 0;
}
vector<int> kh;
if(vp%600!=0){kh.push_back(vp-1);}
if(vp%600!=599){kh.push_back(vp+1);}
if((vp-600)>=0){kh.push_back(vp-600);}
if((vp+600)<360000){kh.push_back(vp+600);}
if(vt<=7){
for(auto &nx : kh){
if(dp[nx][vt]>od.first+len[vt]){
dp[nx][vt]=od.first+len[vt];
pq.push({od.first+len[vt],{nx,vt}});
}
for(int i=8;i<=14;i++){
if(i-7>=vt){continue;}
if(dp[nx][i]>od.first+eps){continue;}
int nv=7+max(vt,i-7);
if(dp[nx][i]+len[i-7]+eps>=od.first){
double reml=max(0.0,1000.0-(od.first-dp[nx][i])*(i-7.0));
double kgl=reml*vt/(i+vt-7.0);
double kgt=reml/(i+vt-7.0);
//cout << reml << ' ' << kgl << ',' << kgt << '\n';
int tg=vp;
double nt=od.first+2.0*kgt;
if(dp[tg][nv]>nt){
dp[tg][nv]=nt;
pq.push({nt,{tg,nv}});
}
tg=nx;
nt=od.first+kgt+(1000.0-kgl)/(nv-7.0);
if(dp[tg][nv]>nt){
dp[tg][nv]=nt;
pq.push({nt,{tg,nv}});
}
}
}
}
}
else{
for(auto &nx : kh){
if(dp[nx][vt]>od.first+len[vt-7]){
dp[nx][vt]=od.first+len[vt-7];
pq.push({od.first+len[vt-7],{nx,vt}});
}
for(int i=1;i<=7;i++){
if(vt-7>=i){continue;}
if(dp[nx][i]>od.first+eps){continue;}
int nv=7+max(vt-7,i);
if(dp[nx][i]+len[i]+eps>=od.first){
double reml=max(0.0,1000.0-(od.first-dp[nx][i])*((double)i));
double kgl=reml*(vt-7.0)/(i+vt-7.0);
double kgt=reml/(i+vt-7.0);
//cout << reml << ' ' << kgl << '@' << kgt << '\n';
int tg=vp;
double nt=od.first+2.0*kgt;
if(dp[tg][nv]>nt){
dp[tg][nv]=nt;
pq.push({nt,{tg,nv}});
}
tg=nx;
nt=od.first+kgt+(1000.0-kgl)/(nv-7.0);
if(dp[tg][nv]>nt){
dp[tg][nv]=nt;
pq.push({nt,{tg,nv}});
}
}
}
}
}
}
return 0;
}