結果

問題 No.1 道のショートカット
ユーザー ゆるくゆるく
提出日時 2014-10-25 05:43:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,148 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 9,564 KB
最終ジャッジ日時 2023-09-22 11:44:10
合計ジャッジ時間 3,128 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
9,288 KB
testcase_01 AC 26 ms
9,268 KB
testcase_02 AC 26 ms
9,244 KB
testcase_03 AC 26 ms
9,276 KB
testcase_04 WA -
testcase_05 AC 25 ms
9,248 KB
testcase_06 AC 26 ms
9,316 KB
testcase_07 AC 26 ms
9,288 KB
testcase_08 AC 29 ms
9,404 KB
testcase_09 AC 28 ms
9,368 KB
testcase_10 AC 28 ms
9,448 KB
testcase_11 AC 29 ms
9,512 KB
testcase_12 WA -
testcase_13 AC 29 ms
9,564 KB
testcase_14 AC 25 ms
9,284 KB
testcase_15 AC 26 ms
9,292 KB
testcase_16 WA -
testcase_17 AC 25 ms
9,212 KB
testcase_18 AC 25 ms
9,300 KB
testcase_19 AC 26 ms
9,256 KB
testcase_20 AC 26 ms
9,268 KB
testcase_21 AC 26 ms
9,208 KB
testcase_22 AC 26 ms
9,344 KB
testcase_23 AC 28 ms
9,408 KB
testcase_24 AC 27 ms
9,384 KB
testcase_25 AC 27 ms
9,284 KB
testcase_26 AC 26 ms
9,348 KB
testcase_27 AC 28 ms
9,484 KB
testcase_28 AC 26 ms
9,256 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 27 ms
9,312 KB
testcase_32 AC 28 ms
9,276 KB
testcase_33 AC 26 ms
9,404 KB
testcase_34 AC 27 ms
9,432 KB
testcase_35 AC 26 ms
9,416 KB
testcase_36 AC 27 ms
9,424 KB
testcase_37 AC 27 ms
9,512 KB
testcase_38 AC 25 ms
9,364 KB
testcase_39 AC 27 ms
9,272 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 26 ms
9,312 KB
testcase_43 AC 27 ms
9,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
from collections import defaultdict, deque
n = int(input())
c = int(input())
v = int(input())
s = tuple(map(int, input().split()))
t = tuple(map(int, input().split()))
y = tuple(map(int, input().split()))
m = tuple(map(int, input().split()))

d = defaultdict(dict)
for i in range(v):
    try:
        if ((d[s[i]][t[i]] >> 16) & 0xFFFFFFFF) > m[i]:
            d[s[i]][t[i]] = (m[i] << 16) + y[i]
    except:
        d[s[i]][t[i]] = (m[i] << 16) + y[i]
def solve():
    heap = []
    heapq.heappush(heap, (0 << 32) + (0 << 16) + 1)
    while (heap):
        h = heapq.heappop(heap)
        hm = (h >> 32) & 0xFFFFFFFF
        hcost = (h >> 16) & 0xFFFF
        hpos = h & 0xFFFF
        if hpos == n:
            return hm
        else:
            for dd in d[hpos]:
                nextcost = (d[hpos][dd] & 0xFFFF) + hcost
                nexthm = ((d[hpos][dd] >> 16) & 0xFFFFFFFF) + hm
                if nextcost <= c:
                    heapq.heappush(heap, (nexthm << 32) + (nextcost << 16) + dd)
    return -1
print(solve())
0