結果

問題 No.1599 Hikyaku
ユーザー butsurizukibutsurizuki
提出日時 2021-05-11 04:00:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,274 bytes
コンパイル時間 2,669 ms
コンパイル使用メモリ 186,704 KB
実行使用メモリ 63,288 KB
最終ジャッジ日時 2023-09-14 06:55:29
合計ジャッジ時間 52,760 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
52,700 KB
testcase_01 AC 333 ms
58,116 KB
testcase_02 AC 489 ms
58,468 KB
testcase_03 AC 15 ms
52,748 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1,830 ms
63,288 KB
testcase_08 AC 1,743 ms
63,120 KB
testcase_09 AC 1,826 ms
57,568 KB
testcase_10 AC 1,975 ms
53,352 KB
testcase_11 AC 1,615 ms
52,904 KB
testcase_12 AC 644 ms
52,976 KB
testcase_13 AC 652 ms
53,020 KB
testcase_14 AC 61 ms
52,896 KB
testcase_15 AC 158 ms
52,812 KB
testcase_16 AC 16 ms
52,696 KB
testcase_17 WA -
testcase_18 AC 330 ms
55,500 KB
testcase_19 AC 2,550 ms
62,440 KB
testcase_20 AC 2,529 ms
62,012 KB
testcase_21 AC 2,577 ms
54,780 KB
testcase_22 AC 2,561 ms
54,572 KB
testcase_23 AC 2,632 ms
53,416 KB
testcase_24 AC 2,672 ms
53,344 KB
testcase_25 AC 2,639 ms
52,836 KB
testcase_26 AC 2,238 ms
52,828 KB
testcase_27 AC 1,340 ms
52,992 KB
testcase_28 AC 1,341 ms
53,012 KB
testcase_29 AC 887 ms
52,796 KB
testcase_30 AC 386 ms
52,928 KB
testcase_31 AC 179 ms
52,992 KB
testcase_32 AC 98 ms
52,728 KB
testcase_33 AC 236 ms
52,748 KB
testcase_34 AC 483 ms
52,852 KB
testcase_35 AC 885 ms
53,076 KB
testcase_36 AC 1,314 ms
52,972 KB
testcase_37 AC 1,315 ms
52,964 KB
testcase_38 AC 1,273 ms
53,072 KB
testcase_39 AC 1,313 ms
53,796 KB
testcase_40 AC 1,353 ms
55,452 KB
testcase_41 AC 15 ms
52,828 KB
testcase_42 AC 144 ms
52,900 KB
testcase_43 AC 119 ms
52,832 KB
testcase_44 WA -
testcase_45 AC 24 ms
52,840 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 14 ms
52,692 KB
testcase_50 AC 15 ms
52,876 KB
testcase_51 AC 15 ms
52,708 KB
testcase_52 AC 616 ms
53,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#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}});
        }
      }
    }
    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 sz=0;sz<2*kh.size();sz++){
      int pst=vp;
      int pfi=kh[sz%kh.size()];
      if(sz<kh.size()){swap(pst,pfi);}
      for(int i=8;i<=14;i++){
        int isp;
        if(i<=7){isp=i;}else{isp=i-7;}
        double cpos=0.0;
        double ctim=dp[pst][i];
        if(ctim==1.0e9){continue;}
        int jst,jfi;
        if(i<=7){jst=i+7+1;jfi=14;}
        else{jst=i-7+1;jfi=7;}

        while(jst<=jfi){
          bool fl=true;
          cpos=0.0;ctim=dp[pst][i];
          int csp=isp;
          for(int j=jst;j<=jfi;j++){
            int jsp;
            if(j<=7){jsp=j;}else{jsp=j-7;}
            if(dp[pfi][j]==1.0e9){continue;}
            double dist,delt,merg=0.0;
            dist=(1000.0-cpos);
            if(ctim>dp[pfi][j]){
              delt=ctim-dp[pfi][j];
              merg=delt;
              dist-=delt*jsp;
            }
            if(ctim<dp[pfi][j]){
              delt=dp[pfi][j]-ctim;
              merg=0.0;
              dist-=delt*csp;
            }
            if(dist<0.0){continue;}
            fl=false;
            if(ctim<dp[pfi][j]){
              cpos+=delt*csp;
              ctim=dp[pfi][j];
            }
            double nt=dist/(double)(csp+jsp);
            cpos+=(dist*(csp+jsp))/(double)csp;
            csp=jsp;
            ctim+=nt;
            nt+=ctim;
            nt+=merg;
            if(dp[pfi][jsp+7]>nt){
              dp[pfi][jsp+7]=nt;
              pq.push({nt,{pfi,jsp+7}});
            }
            jst=j+1;
          }
          if(fl){break;}
        }
      }
    }
  }
  return 0;
}
0