結果
| 問題 |
No.1413 Dynamic Sushi
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-01 01:11:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 478 ms / 4,000 ms |
| コード長 | 3,464 bytes |
| コンパイル時間 | 1,720 ms |
| コンパイル使用メモリ | 198,336 KB |
| 最終ジャッジ日時 | 2025-01-19 08:51:27 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#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";
}