結果
| 問題 |
No.1812 Uribo Road
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2024-11-22 11:37:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 582 bytes |
| コンパイル時間 | 602 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 1,118,980 KB |
| 最終ジャッジ日時 | 2024-11-22 11:39:16 |
| 合計ジャッジ時間 | 80,359 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 TLE * 11 MLE * 5 |
ソースコード
n,m,k=map(int,input().split())
r=[-1]*m
for i,v in enumerate(list(map(int,input().split()))):
r[v-1]=i
e=[[] for i in range(n)]
for i in range(m):
a,b,c=map(int,input().split())
a-=1
b-=1
e[a]+=[(i,b,c)]
e[b]+=[(i,a,c)]
from heapq import heappush,heappop
X=10**10
v=[[X]*n for i in range(1<<k)]
v[0][0]=0
q=[(0,0,0)]
while len(q)>0:
sc,sp,sy=heappop(q)
if sc>v[sp][sy]:
continue
for i,ty,tc in e[sy]:
if r[i]!=-1:
tp=sp|(1<<r[i])
else:
tp=sp
if v[tp][ty]>sc+tc:
v[tp][ty]=sc+tc
heappush(q,(v[tp][ty],tp,ty))
print(v[-1][-1])
sasa8uyauya