結果

問題 No.1599 Hikyaku
ユーザー butsurizukibutsurizuki
提出日時 2021-05-11 04:10:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,352 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 176,436 KB
実行使用メモリ 62,968 KB
最終ジャッジ日時 2023-09-14 06:56:25
合計ジャッジ時間 54,187 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
52,720 KB
testcase_01 AC 343 ms
57,780 KB
testcase_02 AC 498 ms
57,848 KB
testcase_03 AC 15 ms
52,688 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1,913 ms
61,688 KB
testcase_08 AC 1,857 ms
62,252 KB
testcase_09 AC 1,921 ms
56,760 KB
testcase_10 AC 2,120 ms
53,384 KB
testcase_11 AC 1,739 ms
53,080 KB
testcase_12 AC 691 ms
52,848 KB
testcase_13 AC 686 ms
52,828 KB
testcase_14 AC 63 ms
52,748 KB
testcase_15 AC 154 ms
52,752 KB
testcase_16 AC 16 ms
52,832 KB
testcase_17 AC 109 ms
55,492 KB
testcase_18 AC 340 ms
55,544 KB
testcase_19 AC 2,670 ms
62,968 KB
testcase_20 AC 2,628 ms
62,860 KB
testcase_21 AC 2,630 ms
54,576 KB
testcase_22 AC 2,675 ms
54,436 KB
testcase_23 AC 2,752 ms
53,232 KB
testcase_24 AC 2,703 ms
53,344 KB
testcase_25 AC 2,783 ms
52,876 KB
testcase_26 AC 2,304 ms
52,960 KB
testcase_27 AC 1,348 ms
52,820 KB
testcase_28 AC 1,381 ms
52,856 KB
testcase_29 AC 916 ms
53,008 KB
testcase_30 AC 398 ms
52,772 KB
testcase_31 AC 176 ms
52,832 KB
testcase_32 AC 96 ms
52,780 KB
testcase_33 AC 238 ms
52,964 KB
testcase_34 AC 527 ms
52,804 KB
testcase_35 AC 947 ms
52,828 KB
testcase_36 AC 1,394 ms
52,872 KB
testcase_37 AC 1,366 ms
52,820 KB
testcase_38 AC 1,329 ms
53,012 KB
testcase_39 AC 1,366 ms
53,792 KB
testcase_40 AC 1,400 ms
55,448 KB
testcase_41 AC 15 ms
52,724 KB
testcase_42 AC 140 ms
52,724 KB
testcase_43 AC 127 ms
52,932 KB
testcase_44 AC 15 ms
52,844 KB
testcase_45 AC 24 ms
52,756 KB
testcase_46 AC 16 ms
52,728 KB
testcase_47 AC 16 ms
52,756 KB
testcase_48 AC 16 ms
52,728 KB
testcase_49 AC 16 ms
52,776 KB
testcase_50 AC 16 ms
52,784 KB
testcase_51 AC 16 ms
52,876 KB
testcase_52 AC 649 ms
53,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;}
    //cerr << od.first << ':';
    //cerr << vp << ' ';
    //cerr << 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)/(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