結果

問題 No.1413 Dynamic Sushi
ユーザー siro53siro53
提出日時 2021-03-01 01:11:06
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 553 ms / 4,000 ms
コード長 3,464 bytes
コンパイル時間 2,362 ms
コンパイル使用メモリ 199,676 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 03:23:18
合計ジャッジ時間 14,130 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 499 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 496 ms
6,940 KB
testcase_05 AC 524 ms
6,940 KB
testcase_06 AC 532 ms
6,944 KB
testcase_07 AC 530 ms
6,940 KB
testcase_08 AC 521 ms
6,940 KB
testcase_09 AC 543 ms
6,944 KB
testcase_10 AC 529 ms
6,940 KB
testcase_11 AC 531 ms
6,944 KB
testcase_12 AC 541 ms
6,944 KB
testcase_13 AC 535 ms
6,940 KB
testcase_14 AC 546 ms
6,944 KB
testcase_15 AC 548 ms
6,944 KB
testcase_16 AC 542 ms
6,940 KB
testcase_17 AC 548 ms
6,944 KB
testcase_18 AC 553 ms
6,944 KB
testcase_19 AC 540 ms
6,940 KB
testcase_20 AC 230 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 526 ms
6,940 KB
testcase_23 AC 536 ms
6,944 KB
testcase_24 AC 533 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "/home/siro53/kyo-pro/compro_library/template/template.cpp"
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
#line 2 "b.cpp"

using Pd = pair<double, double>;

const double PI = acos(-1);
int N, W;
int X[20], Y[20], R[20], V[20], A[20];

double dp[1 << 20][20];

// i番目の寿司の時刻tの位置
Pd get_pos(int i, double t) {
    double x = double(X[i]) + R[i] * cos((V[i] * t + A[i]) * PI / 180.0);
    double y = double(Y[i]) + R[i] * sin((V[i] * t + A[i]) * PI / 180.0);
    return Pd(x, y);
}

// from -> to に速度Wでlimit_time以内で到達できるか
bool check(Pd from, Pd to, double limit_time) {
    double x = from.first - to.first;
    double y = from.second - to.second;
    double d = sqrt(x * x + y * y);

    return (d <= limit_time * W);
}

int main() {
    cin >> N >> W;
    REP(i, N) cin >> X[i] >> Y[i] >> R[i] >> V[i] >> A[i];

    // 初期化
    REP(S, 1 << N) REP(i, N) dp[S][i] = LLINF;
    REP(i, N) {
        double ok = 1e5, ng = 0.0;
        REP(_, 50) {
            double mid = (ok + ng) / 2.0;
            (check(Pd(0, 0), get_pos(i, mid), mid) ? ok : ng) = mid;
        }
        dp[1 << i][i] = ok;
    }

    REP(S, 1 << N) {
        REP(i, N) {
            if((S >> i & 1) == 0) continue;
            if(dp[S][i] == LLINF) continue;
            Pd from = get_pos(i, dp[S][i]);
            REP(j, N) {
                if(S >> j & 1) continue;
                double ok = 1e5, ng = 0.0;
                REP(_, 50) {
                    double mid = (ok + ng) / 2.0;
                    Pd to = get_pos(j, dp[S][i] + mid);
                    (check(from, to, mid) ? ok : ng) = mid;
                }
                chmin(dp[S | (1 << j)][j], dp[S][i] + ok);
            }
        }
    }

    double ans = LLINF;
    REP(i, N) chmin(ans, dp[(1 << N) - 1][i]);

    cout << ans << "\n";
}
0