結果
| 問題 |
No.1413 Dynamic Sushi
|
| コンテスト | |
| ユーザー |
leaf_1415
|
| 提出日時 | 2021-03-01 17:56:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,044 ms / 4,000 ms |
| コード長 | 2,582 bytes |
| コンパイル時間 | 1,059 ms |
| コンパイル使用メモリ | 85,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-03 00:54:48 |
| 合計ジャッジ時間 | 22,604 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define reps(x, s) for(llint (x) = 0; (x) < (llint)(s).size(); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define ceildiv(x, y) (((x)+(y)-1) / (y))
#define all(x) (x).begin(),(x).end()
#define outl(x) cout << x << endl
#define SP << " " <<
#define inf 1e18
#define eps 1e-9
using namespace std;
typedef long long llint;
typedef long long ll;
typedef pair<llint, llint> P;
bool exceed(ll x, ll y, ll m){return x >= m / y + 1;}
struct vec2d{
double x, y;
vec2d(){}
vec2d(double x, double y){
this->x = x, this->y = y;
}
double add(double a, double b){
if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0;
return a+b;
}
vec2d operator+(vec2d ope){
return vec2d(add(x, ope.x), add(y, ope.y));
}
vec2d operator-(vec2d ope){
return vec2d(add(x, -ope.x), add(y, -ope.y));
}
vec2d operator*(double t){
return vec2d(x*t, y*t);
}
vec2d operator/(double t){
return vec2d(x/t, y/t);
}
double dot(vec2d ope){
return add(x*ope.x, y*ope.y);
}
double cross(vec2d ope){
return add(x*ope.y, -y*ope.x);
}
double norm(){
double d2 = dot(*this);
if(d2 > 0) return sqrt(d2);
return 0.0;
}
};
double distPP(vec2d p, vec2d q){
return (p-q).norm();
}
ll n; double w;
vec2d p[15];
double r[15], v[15], a[15];
double dp[1<<13][13];
int main(void)
{
//ios::sync_with_stdio(0);
//cin.tie(0);
cin >> n >> w;
rep(i, 0, n-1) cin >> p[i].x >> p[i].y >> r[i] >> v[i] >> a[i];
n++;
ll N = 1<<n;
rep(i, 0, N-1) rep(j, 0, n-1) dp[i][j] = inf;
dp[1<<(n-1)][n-1] = 0;
rep(i, 0, N-1){
rep(j, 0, n-1){
if(dp[i][j] > inf/2) continue;
rep(k, 0, n-1){
if(i & (1<<k)) continue;
double ang = (v[j]*dp[i][j]+a[j]) * M_PI / 180.0;
vec2d c = p[j] + vec2d(r[j]*cos(ang), r[j]*sin(ang));
double ub = 1e9, lb = 0, mid;
rep(l, 1, 100){
mid = (ub+lb)/2;
double ang2 = (v[k]*(dp[i][j]+mid)+a[k]) * M_PI / 180.0;
vec2d c2 = p[k] + vec2d(r[k]*cos(ang2), r[k]*sin(ang2));
if(distPP(c, c2) <= w*mid) ub = mid;
else lb = mid;
}
chmin(dp[i|(1<<k)][k], dp[i][j] + lb);
}
}
}
double ans = inf;
rep(i, 0, n-1) chmin(ans, dp[N-1][i]);
printf("%.11f\n", ans);
return 0;
}
leaf_1415