結果

問題 No.1413 Dynamic Sushi
ユーザー 沙耶花
提出日時 2021-02-28 21:36:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 828 ms / 4,000 ms
コード長 1,662 bytes
コンパイル時間 4,470 ms
コンパイル使用メモリ 256,872 KB
最終ジャッジ日時 2025-01-19 08:29:06
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 1e9
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(_,60){
						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;
}
0