結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2019-12-26 18:14:06 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,091 bytes |
| コンパイル時間 | 133 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-07-08 05:19:40 |
| 合計ジャッジ時間 | 2,434 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 WA * 4 |
ソースコード
from heapq import *
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def main():
n = II()
inf=1000
money = II()
m = II()
uu = LI1()
vv = LI1()
cc = LI()
tt = LI()
to = defaultdict(list)
for u, v, c, t in zip(uu, vv, cc, tt):
to[u].append([v, c, t])
to[v].append([u, c, t])
hp=[]
costs=[inf]*n
#[時間,都市,コスト]
heappush(hp,[0,0,0])
while hp:
time,u,cost=heappop(hp)
if u==n-1:
print(time)
exit()
if cost>costs[u]:continue
costs[u]=cost
for v,c,t in to[u]:
if cost+c>money:continue
heappush(hp,[time+t,v,cost+c])
print(-1)
main()
mkawa2