結果
| 問題 |
No.1413 Dynamic Sushi
|
| コンテスト | |
| ユーザー |
emthrm
|
| 提出日時 | 2021-02-28 21:39:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,985 bytes |
| コンパイル時間 | 1,970 ms |
| コンパイル使用メモリ | 203,108 KB |
| 最終ジャッジ日時 | 2025-01-19 08:31:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 21 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
IOSetup() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
std::cout << fixed << setprecision(20);
}
} iosetup;
int main() {
int n, w; cin >> n >> w;
vector<int> 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 sushi_pos = [&](double t, int sushi) -> pair<double, double> {
return {x[sushi] + r[sushi] * cos((v[sushi] * t + a[sushi]) * M_PI / 180),
y[sushi] + r[sushi] * sin((v[sushi] * t + a[sushi]) * M_PI / 180),};
};
auto f = [&](double t, double runx, double runy, int sushi) {
double lb = t, ub = INF;
REP(_, 80) {
double m = (lb + ub) / 2;
auto [sy, sx] = sushi_pos(m, sushi);
(sqrt(pow(runx - sx, 2) + pow(runy - sy, 2)) < w * (m - t) + EPS ? ub : lb) = m;
}
return ub;
};
vector dp(1 << n, vector(n, 1. * INF));
REP(i, n) dp[1 << i][i] = f(0, 0, 0, i);
FOR(b, 1, 1 << n) REP(p, n) {
if (b >> p & 1) {
auto [sy, sx] = sushi_pos(dp[b][p], p);
REP(i, n) {
if (b >> i & 1) continue;
chmin(dp[b | (1 << i)][i], f(dp[b][p], sy, sx, i));
}
}
}
double ans = INF;
REP(i, n) chmin(ans, dp[(1 << n) - 1][i]);
cout << ans << '\n';
return 0;
}
emthrm