結果

問題 No.1599 Hikyaku
ユーザー butsurizukibutsurizuki
提出日時 2021-05-11 04:33:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,849 bytes
コンパイル時間 2,799 ms
コンパイル使用メモリ 221,328 KB
実行使用メモリ 66,572 KB
最終ジャッジ日時 2023-09-14 07:01:19
合計ジャッジ時間 110,196 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 60 ms
56,824 KB
testcase_05 AC 132 ms
57,556 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4,294 ms
61,208 KB
testcase_10 WA -
testcase_11 AC 5,022 ms
55,996 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 442 ms
56,072 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 16 ms
55,884 KB
testcase_42 WA -
testcase_43 AC 1,608 ms
55,912 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

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){
      if(dp[sx[i]*600+sy[i]][sv[i]]>0.0){
        dp[sx[i]*600+sy[i]][sv[i]]=0.0;
        pq.push({0.0,{sx[i]*600+sy[i],sv[i]}});
      }
    }
    else{
      if(dp[sx[i]*600+sy[i]][7+sv[i]]>0.0){
        dp[sx[i]*600+sy[i]][7+sv[i]]=0.0;
        pq.push({0.0,{sx[i]*600+sy[i],7+sv[i]}});
      }
    }
  }
  double lh[393939];
  for(int i=0;i<393939;i++){lh[i]=-1.0;}

  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;}
    //if(vt>=8){
    //  cerr << od.first << ':';
    //  cerr << vp << ' ';
    //  cerr << vt << '\n';
    //}
    if(od.second.first==rd && vt>=8){
      printf("%.12lf\n",od.first);
      return 0;
    }
    if(vt>=8){
      if(lh[vp]<0.0){lh[vp]=od.first;}
      lh[vp]=min(lh[vp],od.first);
    }
    if(lh[vp]>=0.0){
      for(int i=8;i<=14;i++){
        if(dp[vp][i]>lh[vp]){
          dp[vp][i]=lh[vp];
          pq.push({lh[vp],{vp,i}});
        }
      }
    }
    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)/(double)(csp+jsp);
            //cout << vp << ' ' << vt << ' ' << ctim+nt << ' ' <<cpos <<  ' ' << isp << ' ' << jsp << '\n';
            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