結果

問題 No.1413 Dynamic Sushi
ユーザー 👑 emthrmemthrm
提出日時 2021-02-28 21:43:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,136 bytes
コンパイル時間 2,515 ms
コンパイル使用メモリ 203,800 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-12 10:38:05
合計ジャッジ時間 16,293 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 598 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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 + 105;
    REP(_, 80) {
      double m = (lb + ub) / 2;
      auto [sy, sx] = 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. * 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;
}
0