結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2020-01-21 00:49:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,044 bytes |
| コンパイル時間 | 149 ms |
| コンパイル使用メモリ | 82,136 KB |
| 実行使用メモリ | 79,220 KB |
| 最終ジャッジ日時 | 2024-07-08 05:20:41 |
| 合計ジャッジ時間 | 3,993 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 34 WA * 4 RE * 2 |
ソースコード
from collections import deque
N = int(input())
C = int(input())
V = int(input())
Sori = list(map(int,input().split()))
Tori = list(map(int,input().split()))
Yori = list(map(int,input().split()))
Mori = list(map(int,input().split()))
dic = {}
for i in range(V):
s = Sori[i]-1
t = Tori[i]-1
y = Yori[i]
m = Mori[i]
if s not in dic:
dic[s] = []
if t not in dic:
dic[t] = []
dic[s].append([t,y,m])
dic[t].append([s,y,m])
lis = [[float("inf")] * (C+1) for i in range(N) ]
lis[0][0] = 0
q = deque([])
q.append([0,0])
while len(q) > 0:
now = q.popleft()
np = now[0]
nc = now[1]
for i in dic[np]:
nexp = i[0]
nexc = i[1]
dis = i[2]
if nc + nexc <= C:
if lis[nexp][nc+nexc] > lis[np][nc] + dis:
lis[nexp][nc+nexc] = lis[np][nc] + dis
q.append([nexp,nc+nexc])
ans = float("inf")
for i in range(C+1):
ans = min(ans , lis[-1][i])
if ans == float("inf"):
print (-1)
else:
print (ans)
SPD_9X2