結果

問題 No.1413 Dynamic Sushi
ユーザー fumofumofunifumofumofuni
提出日時 2021-02-28 22:01:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,705 ms / 4,000 ms
コード長 2,595 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 203,732 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 10:47:33
合計ジャッジ時間 75,625 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3,194 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3,046 ms
6,940 KB
testcase_05 AC 3,374 ms
6,940 KB
testcase_06 AC 3,458 ms
6,940 KB
testcase_07 AC 3,504 ms
6,944 KB
testcase_08 AC 3,415 ms
6,944 KB
testcase_09 AC 3,651 ms
6,940 KB
testcase_10 AC 3,412 ms
6,944 KB
testcase_11 AC 3,528 ms
6,940 KB
testcase_12 AC 3,683 ms
6,940 KB
testcase_13 AC 3,681 ms
6,940 KB
testcase_14 AC 3,695 ms
6,944 KB
testcase_15 AC 3,642 ms
6,940 KB
testcase_16 AC 3,574 ms
6,940 KB
testcase_17 AC 3,652 ms
6,940 KB
testcase_18 AC 3,705 ms
6,940 KB
testcase_19 AC 3,523 ms
6,944 KB
testcase_20 AC 1,514 ms
6,944 KB
testcase_21 AC 14 ms
6,940 KB
testcase_22 AC 3,484 ms
6,940 KB
testcase_23 AC 3,622 ms
6,940 KB
testcase_24 AC 3,598 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
 ll MOD=1000000007;
 ll MOD9=998244353;
 int inf=1e9+10;
 ll INF=4e18;
 ll dy[8]={1,0,-1,0,1,1,-1,-1};
 ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
 
using ld=long double;
struct sushi{
    ld x,y,r,v,a;
};
struct point{
    ld x,y;
};
ld w;
const ld pi=3.1415926535;
ld dist(point a,point b){
    ld len=(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
    return sqrt(len);
}
pair<ld,point> calc(sushi s,point p,ld time){//pとsの出会う最小の時間とその座標
    ld ng=0,ok=inf;
    ll loop=100;
    point ret;
    while(loop--){
        ld mid=(ok+ng)/2;
        ld now=time+mid;
        ret.x=s.x+s.r*cos((s.v*now+s.a)*pi/180);
        ret.y=s.y+s.r*sin((s.v*now+s.a)*pi/180);
        ld need=dist(ret,p)/w;
        if(need<=mid)ok=mid;
        else ng=mid;
    }   
    return {time+ok,ret};
}


int main(){
    ll n;cin >> n >>w;
    vector<sushi> s(n);
    rep(i,n){
        cin >> s[i].x >> s[i].y >> s[i].r >> s[i].v >> s[i].a;
    }
    point start;start.x=0,start.y=0;
    /*rep(i,3){
        auto ans=calc(s[i],start,0);
        cout << ans.se.x <<" " << ans.se.y <<endl;
        cout << ans.fi <<endl;
    }*/
    vector<vector<pair<ld,point>>> dp(1<<n,vector<pair<ld,point>>(n));
    rep(bit,1<<n)rep(i,n)dp[bit][i]={INF,start};
    rep(i,n){
        dp[1<<i][i]=calc(s[i],start,0);
    }
    rep(bit,1<<n){
        rep(i,n){
            if(!(bit&(1<<i)))continue;
            rep(j,n){
                if(bit&(1<<j))continue;//i->j
                auto to=calc(s[j],dp[bit][i].se,dp[bit][i].fi);
                if(dp[bit|(1<<j)][j].fi>to.fi){
                    dp[bit|(1<<j)][j]=to;
                }
            }

        }
    }
    CST(10);
    ld ans=INF;
    rep(i,n){
        //cout << dp[(1<<n)-1][i].fi <<endl;
        chmin(ans,dp[(1<<n)-1][i].fi);
    }
    cout << ans <<endl;
}
0