結果

問題 No.2387 Yokan Factory
ユーザー ShirotsumeShirotsume
提出日時 2023-07-21 21:27:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,795 ms / 5,000 ms
コード長 1,433 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 279,000 KB
最終ジャッジ日時 2023-10-21 21:15:52
合計ジャッジ時間 27,060 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
56,132 KB
testcase_01 AC 45 ms
56,132 KB
testcase_02 AC 44 ms
56,132 KB
testcase_03 AC 47 ms
56,132 KB
testcase_04 AC 46 ms
56,132 KB
testcase_05 AC 47 ms
56,132 KB
testcase_06 AC 47 ms
56,132 KB
testcase_07 AC 47 ms
56,132 KB
testcase_08 AC 47 ms
56,132 KB
testcase_09 AC 47 ms
56,132 KB
testcase_10 AC 46 ms
56,132 KB
testcase_11 AC 44 ms
56,132 KB
testcase_12 AC 45 ms
56,132 KB
testcase_13 AC 45 ms
56,132 KB
testcase_14 AC 44 ms
56,132 KB
testcase_15 AC 1,299 ms
267,264 KB
testcase_16 AC 766 ms
246,500 KB
testcase_17 AC 1,930 ms
279,000 KB
testcase_18 AC 2,325 ms
272,636 KB
testcase_19 AC 1,844 ms
266,704 KB
testcase_20 AC 1,330 ms
231,548 KB
testcase_21 AC 2,795 ms
267,484 KB
testcase_22 AC 1,287 ms
223,564 KB
testcase_23 AC 2,068 ms
273,556 KB
testcase_24 AC 1,010 ms
197,144 KB
testcase_25 AC 1,268 ms
223,056 KB
testcase_26 AC 2,483 ms
264,768 KB
testcase_27 AC 2,734 ms
267,140 KB
testcase_28 AC 113 ms
77,780 KB
testcase_29 AC 134 ms
78,324 KB
testcase_30 AC 127 ms
78,384 KB
testcase_31 AC 127 ms
78,196 KB
testcase_32 AC 105 ms
77,276 KB
testcase_33 AC 100 ms
77,404 KB
testcase_34 AC 133 ms
78,648 KB
testcase_35 AC 128 ms
78,324 KB
testcase_36 AC 101 ms
77,256 KB
testcase_37 AC 47 ms
58,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
def Dijkstra(s, graph):
    INF = 2 ** 63 - 1
    import heapq
    n = len(graph)
    dist = [INF] * n
    dist[s] = 0
    bef = [0] * n
    bef[s] = s
    hq = [(0, s)]
    heapq.heapify(hq)
    while hq:
        c, now = heapq.heappop(hq)
        
        if c > dist[now]:
            continue
        for to, cost in graph[now]:
            if dist[now] + cost < dist[to]:
                dist[to] = cost + dist[now]
                bef[to] = now
                heapq.heappush(hq, (dist[to], + to))
    return dist, bef

def DijkstraRest(bef, t):
    now = t
    ret = []
    while bef[now] != now:
        ret.append((bef[now], now))
        now = bef[now]
    ret.reverse()
    return ret


n, m, x = mi()

ABCD = [li() for _ in range(m)]

def check(l):
    graph = [[] for _ in range(n + 1)]

    for a, b, c, d in ABCD:
        a -= 1; b -= 1
        if d >= l:
            graph[a].append((b, c))
            graph[b].append((a, c))
    
    d, _ = Dijkstra(0, graph)
    if d[n - 1] <= x:
        return True
    return False

ok = -1

ng = 10 ** 9 + 2

while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if check(mid):
        ok = mid
    else:
        ng = mid
print(ok)
0