結果

問題 No.1413 Dynamic Sushi
ユーザー tanimani364tanimani364
提出日時 2021-04-04 11:32:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 794 ms / 4,000 ms
コード長 2,898 bytes
コンパイル時間 2,371 ms
コンパイル使用メモリ 207,476 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 07:08:11
合計ジャッジ時間 18,577 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 727 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 552 ms
4,376 KB
testcase_05 AC 760 ms
4,380 KB
testcase_06 AC 774 ms
4,376 KB
testcase_07 AC 751 ms
4,376 KB
testcase_08 AC 714 ms
4,376 KB
testcase_09 AC 794 ms
4,376 KB
testcase_10 AC 768 ms
4,380 KB
testcase_11 AC 763 ms
4,380 KB
testcase_12 AC 707 ms
4,380 KB
testcase_13 AC 626 ms
4,380 KB
testcase_14 AC 792 ms
4,376 KB
testcase_15 AC 785 ms
4,376 KB
testcase_16 AC 790 ms
4,376 KB
testcase_17 AC 788 ms
4,380 KB
testcase_18 AC 777 ms
4,376 KB
testcase_19 AC 782 ms
4,376 KB
testcase_20 AC 331 ms
4,376 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 753 ms
4,376 KB
testcase_23 AC 664 ms
4,380 KB
testcase_24 AC 720 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x %= p;
	}
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

void solve()
{	
	int n;
	double w;
	cin>>n>>w;
	vector<double>x(n),y(n),r(n),v(n),a(n);
	rep(i,n)cin>>x[i]>>y[i]>>r[i]>>v[i]>>a[i];
	auto dis=[](pair<double,double> p,pair<double,double> q)->double{
		return (p.first-q.first)*(p.first-q.first)+(p.second-q.second)*(p.second-q.second);
	};
	auto calc=[](double t,double x,double y,double r,double v,double a)->pair<double,double>{
		double pi=acos(-1);
		return {x+r*cos((v*t+a)*pi/180),y+r*sin((v*t+a)*pi/180)};
	};
	constexpr double inf=1e9;
	vector<vector<double>>dp((1<<n)+5,vector<double>(n+1,inf));
	dp[0][n]=0;//nは座標(0,0)
	rep(bit,1<<n){
		rep(j,n+1){
			rep(k,n){
				if(j!=n&&!(bit&1<<j))continue;
				if(bit&1<<k)continue;
				double pre_t=dp[bit][j];
				pair<double,double> pre_pos={0,0};
				if(j!=n)pre_pos=calc(pre_t,x[j],y[j],r[j],v[j],a[j]);
				
				double t=0;
				double left=pre_t,right=1e9;
				rep(cnt,60){
					double mid=(left+right)/2;
					auto cur_pos=calc(mid,x[k],y[k],r[k],v[k],a[k]);
					if(dis(pre_pos,cur_pos)<=w*w*(mid-pre_t)*(mid-pre_t))right=mid;
					else left=mid;
				}
				t=right;
				chmin(dp[bit|1<<k][k],t);
			}
		}
	}
	double ans=inf;
	rep(i,n)chmin(ans,dp[(1<<n)-1][i]);
	cout<<ans<<"\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0