結果

問題 No.1413 Dynamic Sushi
ユーザー 沙耶花沙耶花
提出日時 2021-02-28 21:43:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 574 ms / 4,000 ms
コード長 1,662 bytes
コンパイル時間 4,941 ms
コンパイル使用メモリ 260,424 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 10:38:29
合計ジャッジ時間 15,909 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 483 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 500 ms
6,944 KB
testcase_05 AC 574 ms
6,940 KB
testcase_06 AC 571 ms
6,944 KB
testcase_07 AC 560 ms
6,940 KB
testcase_08 AC 530 ms
6,944 KB
testcase_09 AC 545 ms
6,940 KB
testcase_10 AC 531 ms
6,940 KB
testcase_11 AC 526 ms
6,944 KB
testcase_12 AC 543 ms
6,944 KB
testcase_13 AC 523 ms
6,944 KB
testcase_14 AC 541 ms
6,944 KB
testcase_15 AC 538 ms
6,940 KB
testcase_16 AC 548 ms
6,940 KB
testcase_17 AC 539 ms
6,940 KB
testcase_18 AC 543 ms
6,940 KB
testcase_19 AC 550 ms
6,940 KB
testcase_20 AC 228 ms
6,944 KB
testcase_21 AC 4 ms
6,940 KB
testcase_22 AC 531 ms
6,940 KB
testcase_23 AC 537 ms
6,940 KB
testcase_24 AC 539 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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 5e3
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;
}
0