結果

問題 No.1413 Dynamic Sushi
ユーザー leaf_1415leaf_1415
提出日時 2021-03-01 17:56:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,048 ms / 4,000 ms
コード長 2,582 bytes
コンパイル時間 977 ms
コンパイル使用メモリ 85,980 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 03:45:36
合計ジャッジ時間 22,756 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 881 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 895 ms
6,940 KB
testcase_05 AC 996 ms
6,940 KB
testcase_06 AC 1,003 ms
6,944 KB
testcase_07 AC 1,000 ms
6,940 KB
testcase_08 AC 952 ms
6,940 KB
testcase_09 AC 1,033 ms
6,940 KB
testcase_10 AC 1,003 ms
6,940 KB
testcase_11 AC 1,013 ms
6,944 KB
testcase_12 AC 994 ms
6,944 KB
testcase_13 AC 976 ms
6,940 KB
testcase_14 AC 1,048 ms
6,940 KB
testcase_15 AC 1,032 ms
6,944 KB
testcase_16 AC 1,038 ms
6,940 KB
testcase_17 AC 1,036 ms
6,940 KB
testcase_18 AC 1,028 ms
6,940 KB
testcase_19 AC 1,029 ms
6,940 KB
testcase_20 AC 431 ms
6,940 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 988 ms
6,944 KB
testcase_23 AC 975 ms
6,940 KB
testcase_24 AC 987 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define ceildiv(x, y) (((x)+(y)-1) / (y))
#define all(x) (x).begin(),(x).end()
#define outl(x) cout << x << endl
#define SP << " " << 
#define inf 1e18
#define eps 1e-9

using namespace std;

typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;
bool exceed(ll x, ll y, ll m){return x >= m / y + 1;} 

struct vec2d{
	double x, y;
	vec2d(){}
	vec2d(double x, double y){
		this->x = x, this->y = y;
	}
	double add(double a, double b){
		if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
		return a+b;
	}
	vec2d operator+(vec2d ope){
		return vec2d(add(x, ope.x), add(y, ope.y));
	}
	vec2d operator-(vec2d ope){
		return vec2d(add(x, -ope.x), add(y, -ope.y));
	}
	vec2d operator*(double t){
		return vec2d(x*t, y*t);
	}
	vec2d operator/(double t){
		return vec2d(x/t, y/t);
	}
	double dot(vec2d ope){
		return add(x*ope.x, y*ope.y);
	}
	double cross(vec2d ope){
		return add(x*ope.y, -y*ope.x);
	}
	double norm(){
		double d2 = dot(*this);
		if(d2 > 0) return sqrt(d2);
		return 0.0;
	}
};

double distPP(vec2d p, vec2d q){
	return (p-q).norm();
}

ll n; double w;
vec2d p[15];
double r[15], v[15], a[15];
double dp[1<<13][13];

int main(void)
{
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n >> w;
	rep(i, 0, n-1) cin >> p[i].x >> p[i].y >> r[i] >> v[i] >> a[i];
	n++;
	
	ll N = 1<<n;
	rep(i, 0, N-1) rep(j, 0, n-1) dp[i][j] = inf;
	dp[1<<(n-1)][n-1] = 0;
	
	rep(i, 0, N-1){
		rep(j, 0, n-1){
			if(dp[i][j] > inf/2) continue;
			rep(k, 0, n-1){
				if(i & (1<<k)) continue;
				
				double ang = (v[j]*dp[i][j]+a[j]) * M_PI / 180.0;
				vec2d c = p[j] + vec2d(r[j]*cos(ang), r[j]*sin(ang));
				
				double ub = 1e9, lb = 0, mid;
				rep(l, 1, 100){
					mid = (ub+lb)/2;
					double ang2 = (v[k]*(dp[i][j]+mid)+a[k]) * M_PI / 180.0;
					vec2d c2 = p[k] + vec2d(r[k]*cos(ang2), r[k]*sin(ang2));
					if(distPP(c, c2) <= w*mid) ub = mid;
					else lb = mid;
				}
				chmin(dp[i|(1<<k)][k], dp[i][j] + lb);
			}
		}
	}
	double ans = inf;
	rep(i, 0, n-1) chmin(ans, dp[N-1][i]);
	printf("%.11f\n", ans);
	
	return 0;
}
0