結果

問題 No.1413 Dynamic Sushi
ユーザー 👑 emthrmemthrm
提出日時 2021-03-01 04:07:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 772 ms / 4,000 ms
コード長 2,138 bytes
コンパイル時間 2,701 ms
コンパイル使用メモリ 204,424 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 03:31:15
合計ジャッジ時間 19,049 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 689 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 698 ms
6,940 KB
testcase_05 AC 721 ms
6,944 KB
testcase_06 AC 739 ms
6,940 KB
testcase_07 AC 751 ms
6,944 KB
testcase_08 AC 733 ms
6,940 KB
testcase_09 AC 767 ms
6,944 KB
testcase_10 AC 733 ms
6,940 KB
testcase_11 AC 745 ms
6,944 KB
testcase_12 AC 757 ms
6,940 KB
testcase_13 AC 751 ms
6,940 KB
testcase_14 AC 764 ms
6,944 KB
testcase_15 AC 755 ms
6,940 KB
testcase_16 AC 758 ms
6,944 KB
testcase_17 AC 768 ms
6,940 KB
testcase_18 AC 772 ms
6,940 KB
testcase_19 AC 750 ms
6,940 KB
testcase_20 AC 321 ms
6,944 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 737 ms
6,944 KB
testcase_23 AC 750 ms
6,944 KB
testcase_24 AC 754 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

double dist(double sx, double sy, double tx, double ty) {
  return sqrt((tx - sx) * (tx - sx) + (ty - sy) * (ty - sy));
}

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 = t + dist(runx, runy, x[sushi], y[sushi]) / w + 1000;
    REP(_, 80) {
      double m = (lb + ub) / 2;
      auto [sx, sy] = sushi_pos(m, sushi);
      (dist(runx, runy, sx, sy) < w * (m - t + EPS) ? ub : lb) = m;
    }
    return ub;
  };
  vector dp(1 << n, vector(n, 1. * LINF));
  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 [sx, sy] = sushi_pos(dp[b][p], p);
      REP(i, n) {
        if (b >> i & 1) continue;
        chmin(dp[b | (1 << i)][i], f(dp[b][p], sx, sy, i));
      }
    }
  }
  double ans = LINF;
  REP(i, n) chmin(ans, dp[(1 << n) - 1][i]);
  cout << ans << '\n';
  return 0;
}
0