結果

問題 No.1413 Dynamic Sushi
ユーザー ygd.ygd.
提出日時 2021-03-04 00:25:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,199 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,696 KB
実行使用メモリ 82,004 KB
最終ジャッジ日時 2024-04-14 17:53:21
合計ジャッジ時間 26,498 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
64,896 KB
testcase_01 AC 47 ms
52,992 KB
testcase_02 AC 43 ms
53,632 KB
testcase_03 AC 45 ms
53,760 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1,238 ms
81,116 KB
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 #

import math
import itertools
N,W = map(int,input().split()); INF = 1<<60
X=[];Y=[];R=[];V=[];A=[];SET =set([])
for _ in range(N):
    x,y,r,v,a = map(int,input().split())
    if (x,y,r,v,a) in SET:
        continue
    X.append(x);Y.append(y);R.append(r);V.append(v);A.append(a)
    SET.add((x,y,r,v,a))
#print(X,Y)
def touch(p,q,t,i): #今(p,q)に時間tでいてi番目の寿司を手に入れるのにかかる時間と最後の座標
    x = X[i]; y = Y[i]; r = R[i]; v = V[i]; a = A[i]
    sx = x + r*math.cos(math.radians(v*t+a))
    sy = y + r*math.sin(math.radians(v*t+a))
    if (p,q) == (sx,sy):
        return p,q,t
    ng = 0
    ok = 1000
    E = pow(10,-10)
    while abs(ok-ng) > E:
        mid = (ok+ng)/2
        mx = x + r*math.cos(math.radians(v*(t+mid)+a))
        my = y + r*math.sin(math.radians(v*(t+mid)+a))
        dis2 = pow(mx-p,2) + pow(my-q,2)
        if dis2 <= (mid*W)**2:
            ok = mid
        else:
            ng = mid
    nt = t + ok
    np = x + r*math.cos(math.radians(v*nt+a))
    nq =  y + r*math.sin(math.radians(v*nt+a))
    return np, nq, nt

N = len(SET)+1
#dp[S][v]:= 頂点0からスタートして、{0,1,2,…,n-1} の部分集合 S を巡回する |S|! 通りの経路のうち最後にvとなる最短時間。
dp = [[INF]*N for _ in range(1<<N)]
dp[0][0] = 0
for S in range(1<<N):
    for v in range(N):
        for u in range(N): 
            if S != 0 and S&(1<<u) == 0: #空でないのにuが入っていないとダメ。
                continue
            if S&1<<v == 0: #Sにvがすでに入っていたら見る必要がない。
                if v != u: #集合Sにvを加えたときの最小値
                    t = dp[S][u]
                    if u == 0:
                        x0 = 0
                        y0 = 0
                    else:
                        x0 = X[u-1] + R[u-1]*math.cos(math.radians(V[u-1]*t+A[u-1]))
                        y0 = Y[u-1] + R[u-1]*math.sin(math.radians(V[u-1]*t+A[u-1]))
                    nx,ny,nt = touch(x0,y0,t,v-1)
                    #print("u",u,"v",v,t,nt,nx,ny)
                    dp[S|(1<<v)][v] = min(dp[S|(1<<v)][v], nt)
#print(dp)
ans = dp[(1<<N) - 1][0]
print(ans)
0