結果

問題 No.2387 Yokan Factory
ユーザー ああいいああいい
提出日時 2023-07-22 16:21:45
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 842 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 81,656 KB
実行使用メモリ 209,788 KB
最終ジャッジ日時 2023-10-23 22:43:56
合計ジャッジ時間 10,864 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,400 KB
testcase_01 AC 40 ms
53,400 KB
testcase_02 AC 40 ms
53,400 KB
testcase_03 AC 40 ms
53,400 KB
testcase_04 AC 41 ms
53,400 KB
testcase_05 AC 42 ms
53,400 KB
testcase_06 AC 40 ms
53,400 KB
testcase_07 AC 40 ms
53,400 KB
testcase_08 AC 41 ms
53,400 KB
testcase_09 AC 41 ms
53,400 KB
testcase_10 AC 41 ms
53,400 KB
testcase_11 AC 41 ms
53,400 KB
testcase_12 AC 41 ms
53,400 KB
testcase_13 AC 40 ms
53,400 KB
testcase_14 AC 40 ms
53,400 KB
testcase_15 AC 1,979 ms
209,788 KB
testcase_16 AC 640 ms
143,188 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

N,M,X = map(int,input().split())

G = [[] for _ in range(N)]
for _ in range(M):
    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1
    G[u].append((v,a,b))
    G[v].append((u,a,b))

inf = 1 << 67
B = 70
mask = (1 << B) - 1
def calc(k):
    
    dist = [inf] * N
    dist[0] = 0
    q = [0]
    while q:
        U = heapq.heappop(q)
        d = U >> B
        now = U & mask
        if dist[now] > d:continue
        if now == N - 1:break
        for v,a,b in G[now]:
            if b < k:continue
            if dist[v] > d + a:
                dist[v] = d + a
                heapq.heappush(q,((d + a) << B) + v)
    return dist[-1] <= X
end = 10 ** 9 + 1
start = 0
while end - start > 1:
    mid = end + start >> 1
    if calc(mid):
        start = mid
    else:
        end = mid
print(start if start != 0 else -1)
0