結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
tookunn_1213
|
| 提出日時 | 2016-08-23 01:20:07 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 855 ms / 5,000 ms |
| コード長 | 672 bytes |
| コンパイル時間 | 76 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-07-20 16:24:53 |
| 合計ジャッジ時間 | 6,675 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
import heapq N,C,V = int(input()),int(input()),int(input()) S = [int(i) - 1 for i in input().split()] T = [int(i) - 1 for i in input().split()] Y = [int(i) for i in input().split()] M = [int(i) for i in input().split()] used = [[False for j in range(N)]for i in range(300 + 1)] def dijkstra(s,t): q = [(0,0,s)] ret = 10 ** 9 + 7 while len(q) > 0: d = heapq.heappop(q) if d[1] > C: continue if used[d[1]][d[2]]: continue used[d[1]][d[2]] = True if d[2] == t: ret = min(ret,d[0]) continue for i in range(V): if S[i] == d[2]: heapq.heappush(q,(d[0] + M[i],d[1] + Y[i],T[i])) return -1 if ret == 10 ** 9 + 7 else ret print(dijkstra(0,N - 1))
tookunn_1213