結果
問題 |
No.1413 Dynamic Sushi
|
ユーザー |
![]() |
提出日時 | 2021-02-28 21:42:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,662 bytes |
コンパイル時間 | 4,006 ms |
コンパイル使用メモリ | 258,268 KB |
最終ジャッジ日時 | 2025-01-19 08:32:08 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 1 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint1000000007; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1e3 vector<double> X,Y,R,V,A; pair<double,double> get_pos(int ind,double T){ double x,y; x = X[ind] + R[ind] * cos((V[ind]*T+A[ind])*acos(-1.0)/180.0); y = Y[ind] + R[ind] * sin((V[ind]*T+A[ind])*acos(-1.0)/180.0); return make_pair(x,y); } int main(){ int N; cin>>N; double W; cin>>W; X.resize(N); Y.resize(N); R.resize(N); V.resize(N); A.resize(N); rep(i,N){ cin>>X[i]>>Y[i]>>R[i]>>V[i]>>A[i]; } N++; X.push_back(0); Y.push_back(0); R.push_back(0); V.push_back(1); A.push_back(1); vector dp(1<<N,vector<double>(N,Inf)); dp[1<<(N-1)][N-1] = 0.0; vector<vector<int>> B(N+1); rep(i,1<<N){ int c = 0; rep(j,N){ if((i>>j)&1)c++; } B[c].push_back(i); } rep(i,N){ if(i==0)continue; rep(j,B[i].size()){ int b = B[i][j]; rep(k,N){ if(dp[b][k]==Inf)continue; rep(l,N){ if((b>>l)&1)continue; int nb = b|(1<<l); auto s = get_pos(k,dp[b][k]); double ng = 0.0,ok = Inf; rep(_,45){ double mid = (ok+ng)/2.0; auto t = get_pos(l,dp[b][k]+mid); if(hypot(s.first-t.first,s.second-t.second)<=mid*W)ok = mid; else ng = mid; } dp[nb][l] = min(dp[nb][l],dp[b][k] + ok); } } } } /* rep(i,1<<N){ rep(j,N){ cout<<dp[i][j]<<',';; } cout<<endl; } */ double ans = Inf; rep(i,N){ ans = min(ans,dp.back()[i]); } cout<<fixed<<setprecision(10)<<ans<<endl; return 0; }