結果
| 問題 |
No.1413 Dynamic Sushi
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2021-02-28 22:05:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,289 ms / 4,000 ms |
| コード長 | 1,986 bytes |
| コンパイル時間 | 3,987 ms |
| コンパイル使用メモリ | 258,316 KB |
| 最終ジャッジ日時 | 2025-01-19 08:43:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n)for (int i = 0; i < int(n); ++i)
#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
constexpr double INF = 1e18;
struct P {
int x, y, r, v, a;
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, w;
cin >> n >> w;
vector<vector<double>> dp(n, vector<double>(1 << n, INF));
vector<P> ps(n);
rep(i, n) cin >> ps[i].x >> ps[i].y >> ps[i].r >> ps[i].v >> ps[i].a;
auto pos = [&](int i, double t) -> pair<double, double> {
double theta = (ps[i].v * t + ps[i].a) * (M_PI / 180);
return {ps[i].x + ps[i].r * cos(theta), ps[i].y + ps[i].r * sin(theta)};
};
auto dist = [&](double x0, double y0, double t0, int i) {
double l = t0, r = INF;
rep(_, 120) {
double c = (l >= 1 ? sqrt(l * r) : (l + r) / 2);
auto [tmp_x, tmp_y] = pos(i, c);
tmp_x -= x0; tmp_y -= y0;
double tmp_dist = tmp_x * tmp_x + tmp_y * tmp_y;
double d = (c - t0) * w;
if (d * d >= tmp_dist) r = c;
else l = c;
}
return r;
};
rep(i, n) {
dp[i][1 << i] = dist(0, 0, 0, i);
}
rep(s, 1 << n) rep(i, n) {
double t0 = dp[i][s];
auto [x0, y0] = pos(i, t0);
if (t0 == INF) continue;
rep(j, n) {
if (s & 1 << j) continue;
int ns = s | 1 << j;
chmin(dp[j][ns], dist(x0, y0, t0, j));
}
}
double ans = INF;
rep(i, n) chmin(ans, dp[i][~(~0 << n)]);
cout << fixed << setprecision(16) << ans << endl;
}
Kude