結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
ゆるく
|
| 提出日時 | 2014-11-05 23:37:29 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 100 ms / 5,000 ms |
| コード長 | 1,083 bytes |
| 記録 | |
| コンパイル時間 | 358 ms |
| コンパイル使用メモリ | 20,704 KB |
| 実行使用メモリ | 36,052 KB |
| 最終ジャッジ日時 | 2026-04-03 01:14:31 |
| 合計ジャッジ時間 | 5,846 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
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(lambda : defaultdict(list))
for i in range(v):
d[s[i]][t[i]].append((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]:
for td in d[hpos][dd]:
nextcost = (td & 0xFFFF) + hcost
nexthm = ((td >> 16) & 0xFFFFFFFF) + hm
if nextcost <= c:
heapq.heappush(heap, (nexthm << 32) + (nextcost << 16) + dd)
return -1
print(solve())
ゆるく