結果

問題 No.1413 Dynamic Sushi
ユーザー shotoyooshotoyoo
提出日時 2021-03-01 22:50:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 709 ms / 4,000 ms
コード長 1,355 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 82,468 KB
実行使用メモリ 78,068 KB
最終ジャッジ日時 2024-04-14 03:57:19
合計ジャッジ時間 14,682 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
54,320 KB
testcase_01 AC 448 ms
77,852 KB
testcase_02 AC 38 ms
54,648 KB
testcase_03 AC 38 ms
54,120 KB
testcase_04 AC 490 ms
77,768 KB
testcase_05 AC 659 ms
77,508 KB
testcase_06 AC 676 ms
77,644 KB
testcase_07 AC 642 ms
78,064 KB
testcase_08 AC 597 ms
77,904 KB
testcase_09 AC 709 ms
77,764 KB
testcase_10 AC 666 ms
77,768 KB
testcase_11 AC 667 ms
77,840 KB
testcase_12 AC 614 ms
77,960 KB
testcase_13 AC 585 ms
77,720 KB
testcase_14 AC 691 ms
78,068 KB
testcase_15 AC 680 ms
77,856 KB
testcase_16 AC 690 ms
77,676 KB
testcase_17 AC 697 ms
77,780 KB
testcase_18 AC 663 ms
77,968 KB
testcase_19 AC 679 ms
77,780 KB
testcase_20 AC 329 ms
77,324 KB
testcase_21 AC 61 ms
69,932 KB
testcase_22 AC 631 ms
77,512 KB
testcase_23 AC 605 ms
77,800 KB
testcase_24 AC 605 ms
77,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
import math
def sub(x,y,t,i,ii=None):
    xi,yi,r,v,a = l[i]
    theta = (v*t + a) * math.pi / 180
    w = v*math.pi/180
    ll = 0
    rr = 10**9
    for _ in range(50):
        mm = (ll+rr)/2
        v1 = W**2 * mm**2
        v2 = ((xi + r*math.cos(theta+mm*w) - x) ** 2 + (yi + r*math.sin(theta+mm*w) - y) ** 2)
        if v1<v2:
            ll = mm
        else:
            rr = mm
#     print(mm)
    return (((xi + r*math.cos(theta+mm*w) - x) ** 2 + (yi + r*math.sin(theta+mm*w) - y) ** 2)) ** 0.5 / W
def loc(i,t):
    xi,yi,r,v,a = l[i]
    th = (v*t+a)*math.pi/180
    return xi + r*math.cos(th), yi+r*math.sin(th)
n,W = list(map(int, input().split()))
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
inf = float("inf")
dp = [[inf]*(1<<(n)) for _ in range(n)]
for i in range(n):
    dp[i][1<<i] = sub(0,0,0,i)
def chmin(j,b,val):
    dp[j][b] = min(dp[j][b], val)
for b in range(1<<n):
    for i in range(n):
        if dp[i][b]==inf:
            continue
        for j in range(n):
            if b>>j&1:
                continue
            xx,yy = loc(i,dp[i][b])
            chmin(j, b|(1<<j), dp[i][b]+sub(xx,yy,dp[i][b],j))
ans = min(dp[i][(1<<n)-1] for i in range(n))
print(ans)
0