結果

問題 No.1413 Dynamic Sushi
ユーザー KudeKude
提出日時 2021-02-28 22:05:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,280 ms / 4,000 ms
コード長 1,986 bytes
コンパイル時間 4,859 ms
コンパイル使用メモリ 260,480 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 10:49:53
合計ジャッジ時間 28,109 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1,167 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 918 ms
6,940 KB
testcase_05 AC 1,216 ms
6,944 KB
testcase_06 AC 1,171 ms
6,940 KB
testcase_07 AC 993 ms
6,940 KB
testcase_08 AC 964 ms
6,940 KB
testcase_09 AC 1,209 ms
6,944 KB
testcase_10 AC 1,238 ms
6,940 KB
testcase_11 AC 1,009 ms
6,940 KB
testcase_12 AC 1,021 ms
6,940 KB
testcase_13 AC 1,014 ms
6,940 KB
testcase_14 AC 1,031 ms
6,944 KB
testcase_15 AC 1,016 ms
6,940 KB
testcase_16 AC 1,280 ms
6,944 KB
testcase_17 AC 1,029 ms
6,940 KB
testcase_18 AC 1,038 ms
6,940 KB
testcase_19 AC 1,079 ms
6,944 KB
testcase_20 AC 526 ms
6,940 KB
testcase_21 AC 6 ms
6,940 KB
testcase_22 AC 1,248 ms
6,940 KB
testcase_23 AC 1,005 ms
6,940 KB
testcase_24 AC 1,007 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0