結果

問題 No.1413 Dynamic Sushi
ユーザー kwm_tkwm_t
提出日時 2021-03-01 22:45:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,994 ms / 4,000 ms
コード長 1,862 bytes
コンパイル時間 5,712 ms
コンパイル使用メモリ 227,892 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 03:56:14
合計ジャッジ時間 45,768 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1,744 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1,661 ms
6,944 KB
testcase_05 AC 1,898 ms
6,940 KB
testcase_06 AC 1,914 ms
6,940 KB
testcase_07 AC 1,920 ms
6,940 KB
testcase_08 AC 1,819 ms
6,944 KB
testcase_09 AC 1,994 ms
6,944 KB
testcase_10 AC 1,920 ms
6,940 KB
testcase_11 AC 1,924 ms
6,940 KB
testcase_12 AC 1,910 ms
6,944 KB
testcase_13 AC 1,845 ms
6,944 KB
testcase_14 AC 1,988 ms
6,940 KB
testcase_15 AC 1,966 ms
6,944 KB
testcase_16 AC 1,978 ms
6,944 KB
testcase_17 AC 1,951 ms
6,940 KB
testcase_18 AC 1,951 ms
6,948 KB
testcase_19 AC 1,939 ms
6,944 KB
testcase_20 AC 815 ms
6,944 KB
testcase_21 AC 10 ms
6,940 KB
testcase_22 AC 1,865 ms
6,940 KB
testcase_23 AC 1,832 ms
6,944 KB
testcase_24 AC 1,877 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#include "atcoder/all"
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
double dp[100005][2];
int X[12];
int Y[12];
int R[12];
int V[12];
int A[12];
int N, W;
double PI = acos(-1.0);
double calc(double x0, double y0, double t0, int i) {
	double ng = t0;
	double ok = INF;
	for (int n = 0; n < 100; ++n) {
		double mid = (ok + ng) / 2;
		double x1 = X[i] + R[i] * cos((V[i] * mid + A[i])*PI / 180) - x0;
		double y1 = Y[i] + R[i] * sin((V[i] * mid + A[i])*PI / 180) - y0;
		if ((x1*x1 + y1 * y1) <= (double)W*W*(mid - t0)*(mid - t0)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	return ok;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> W;
	rep(i, N) {
		cin >> X[i] >> Y[i] >> R[i] >> V[i] >> A[i];
	}
	//巡回セールスマン
	vector<vector<double>> dp(1 << N, vector<double>(N, INF));
	rep(i, N) {
		//初期値
		dp[1 << i][i] = calc(0, 0, 0, i);
	}
	rep(i, (1 << N)) {
		rep(j, N) {
			if (INF == dp[i][j]) {
				continue;
			}
			rep(k, N) {
				int next = i | (1 << k);
				double t = dp[i][j];
				double x = X[j] + R[j] * cos((V[j] * t + A[j])*PI / 180);
				double y = Y[j] + R[j] * sin((V[j] * t + A[j])*PI / 180);
				double time = calc(x, y, t, k);
				dp[next][k] = min(dp[next][k], time);
			}
		}
	}
	double ans = INF;
	for (int i = 0; i < N; ++i) {
		ans = min(dp[(1 << N) - 1][i], ans);
	}
	printf("%.10f\n", ans);
	return 0;
}
0