結果

問題 No.2387 Yokan Factory
ユーザー i_takui_taku
提出日時 2023-07-21 21:46:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,029 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 81,688 KB
実行使用メモリ 182,040 KB
最終ジャッジ日時 2023-10-21 21:46:14
合計ジャッジ時間 28,970 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,500 KB
testcase_01 AC 47 ms
55,500 KB
testcase_02 AC 46 ms
55,500 KB
testcase_03 AC 45 ms
55,500 KB
testcase_04 AC 45 ms
55,500 KB
testcase_05 AC 44 ms
55,500 KB
testcase_06 AC 45 ms
55,500 KB
testcase_07 AC 44 ms
55,500 KB
testcase_08 AC 43 ms
55,500 KB
testcase_09 AC 43 ms
55,500 KB
testcase_10 AC 44 ms
55,500 KB
testcase_11 AC 44 ms
55,500 KB
testcase_12 AC 44 ms
55,500 KB
testcase_13 AC 44 ms
55,500 KB
testcase_14 AC 44 ms
55,500 KB
testcase_15 AC 1,230 ms
141,592 KB
testcase_16 AC 769 ms
142,820 KB
testcase_17 WA -
testcase_18 AC 1,882 ms
158,580 KB
testcase_19 AC 2,412 ms
141,476 KB
testcase_20 AC 1,885 ms
132,772 KB
testcase_21 AC 3,072 ms
146,520 KB
testcase_22 AC 1,799 ms
124,176 KB
testcase_23 AC 2,632 ms
145,672 KB
testcase_24 AC 964 ms
112,236 KB
testcase_25 AC 1,567 ms
121,192 KB
testcase_26 AC 2,640 ms
140,112 KB
testcase_27 AC 3,320 ms
182,040 KB
testcase_28 AC 116 ms
77,220 KB
testcase_29 WA -
testcase_30 AC 141 ms
78,144 KB
testcase_31 WA -
testcase_32 AC 89 ms
76,300 KB
testcase_33 AC 99 ms
76,520 KB
testcase_34 WA -
testcase_35 AC 142 ms
78,280 KB
testcase_36 AC 98 ms
76,524 KB
testcase_37 AC 45 ms
55,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline()[:-1]
from heapq import heappush, heappop
from collections import defaultdict

N, M, X = map(int, input().split())
INF = float('inf')
g = [defaultdict(list) for _ in range(N)]

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

    ok = 0
    ng = X + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if dijkstra(mid):
            ok = mid
        else:
            ng = mid
    print(ok if 0 < ok <= X else -1)
    
def dijkstra(s):
    hq = [(0, 0)]
    dist = [INF] * N
    dist[0] = 0
    while hq:
        d, u = heappop(hq)
        if dist[u] < d:
            continue
        for v in g[u]:
            for a, b in g[u][v]:
                if b < s:
                    continue
                if dist[v] > dist[u] + a:
                    dist[v] = dist[u] + a
                    heappush(hq, (dist[v], v))
    return dist[N - 1] <= X

main()
0