結果

問題 No.1814 Uribo Road (Easy)
ユーザー first_vilfirst_vil
提出日時 2022-01-17 13:37:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 79,432 KB
最終ジャッジ日時 2023-08-15 06:57:11
合計ジャッジ時間 10,111 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,228 KB
testcase_01 AC 69 ms
76,096 KB
testcase_02 AC 64 ms
71,560 KB
testcase_03 AC 66 ms
71,304 KB
testcase_04 AC 65 ms
71,232 KB
testcase_05 AC 63 ms
71,288 KB
testcase_06 AC 63 ms
71,400 KB
testcase_07 AC 66 ms
71,348 KB
testcase_08 AC 66 ms
71,440 KB
testcase_09 AC 87 ms
76,960 KB
testcase_10 AC 84 ms
76,836 KB
testcase_11 AC 102 ms
78,088 KB
testcase_12 AC 145 ms
78,772 KB
testcase_13 AC 119 ms
78,272 KB
testcase_14 AC 148 ms
78,844 KB
testcase_15 AC 168 ms
78,064 KB
testcase_16 AC 213 ms
78,056 KB
testcase_17 AC 224 ms
77,656 KB
testcase_18 AC 265 ms
77,684 KB
testcase_19 AC 252 ms
77,820 KB
testcase_20 AC 322 ms
78,640 KB
testcase_21 AC 346 ms
79,432 KB
testcase_22 AC 265 ms
78,516 KB
testcase_23 AC 313 ms
78,832 KB
testcase_24 AC 215 ms
78,788 KB
testcase_25 AC 264 ms
78,584 KB
testcase_26 AC 238 ms
78,704 KB
testcase_27 AC 229 ms
78,804 KB
testcase_28 AC 233 ms
78,736 KB
testcase_29 AC 299 ms
78,588 KB
testcase_30 AC 224 ms
78,332 KB
testcase_31 AC 219 ms
78,104 KB
testcase_32 AC 144 ms
79,012 KB
testcase_33 AC 94 ms
76,896 KB
testcase_34 AC 86 ms
76,456 KB
testcase_35 AC 123 ms
78,124 KB
testcase_36 AC 109 ms
77,900 KB
testcase_37 AC 143 ms
78,656 KB
testcase_38 AC 155 ms
78,756 KB
testcase_39 AC 118 ms
78,200 KB
testcase_40 AC 124 ms
78,764 KB
testcase_41 AC 259 ms
78,836 KB
testcase_42 AC 232 ms
78,836 KB
testcase_43 AC 133 ms
78,600 KB
testcase_44 AC 148 ms
78,996 KB
testcase_45 AC 113 ms
77,896 KB
testcase_46 AC 211 ms
78,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF=float("inf")
n,m,k=map(int,input().split())
q=[-1]*m
for i,r in enumerate(list(map(lambda x: int(x)-1,input().split()))):
    q[r]=i
wf=[[INF]*n for i in range(n)]
e=[334]*k
for i in range(m):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    wf[a][b]=wf[b][a]=c
    if q[i]!=-1:
        e[q[i]]=(a,b,c)

for p in range(n):
    wf[p][p]=0
    for i in range(n):
        for j in range(n):
            wf[i][j]=min(wf[i][j],wf[i][p]+wf[p][j])

dp=[[INF]*n for i in range(2**k)]
dp[0][0]=0
for bit in range(2**k):
    for i in range(n):
        for j in range(n):
            dp[bit][j]=min(dp[bit][j],dp[bit][i]+wf[i][j])
    for i,(a,b,c) in enumerate(e):
        dp[1<<i|bit][a]=min(dp[1<<i|bit][a],dp[bit][b]+c)
        dp[1<<i|bit][b]=min(dp[1<<i|bit][b],dp[bit][a]+c)
print(dp[-1][-1])
0