結果

問題 No.2387 Yokan Factory
ユーザー とろちゃとろちゃ
提出日時 2023-07-21 22:34:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,043 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 268,200 KB
最終ジャッジ日時 2023-10-21 22:34:29
合計ジャッジ時間 34,062 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
55,420 KB
testcase_01 AC 45 ms
55,420 KB
testcase_02 AC 45 ms
55,420 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 44 ms
55,420 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 45 ms
55,420 KB
testcase_11 WA -
testcase_12 AC 44 ms
55,420 KB
testcase_13 AC 44 ms
55,420 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 884 ms
175,952 KB
testcase_17 AC 3,475 ms
268,200 KB
testcase_18 AC 2,760 ms
177,980 KB
testcase_19 AC 2,096 ms
158,304 KB
testcase_20 AC 946 ms
127,252 KB
testcase_21 AC 3,636 ms
196,340 KB
testcase_22 AC 1,175 ms
128,948 KB
testcase_23 AC 3,813 ms
174,152 KB
testcase_24 AC 1,804 ms
134,916 KB
testcase_25 AC 1,566 ms
131,428 KB
testcase_26 AC 2,307 ms
177,956 KB
testcase_27 AC 1,044 ms
153,516 KB
testcase_28 AC 112 ms
77,440 KB
testcase_29 AC 120 ms
78,324 KB
testcase_30 AC 144 ms
78,100 KB
testcase_31 AC 163 ms
77,908 KB
testcase_32 AC 129 ms
77,320 KB
testcase_33 AC 140 ms
77,316 KB
testcase_34 AC 173 ms
78,100 KB
testcase_35 AC 213 ms
78,164 KB
testcase_36 AC 86 ms
70,672 KB
testcase_37 AC 54 ms
55,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1")
# from bisect import *
from collections import *
from heapq import *

# from itertools import *
# from math import *
# from datetime import *
# from decimal import *  # PyPyだと遅い
# from string import ascii_lowercase,ascii_uppercase
# import numpy as np
import sys

# sys.setrecursionlimit(10**6) # PyPyだと遅い
INF = 10**20
MOD = 998244353
# MOD = 10**9 + 7
File = sys.stdin


def input():
    return File.readline()[:-1]


# ///////////////////////////////////////////////////////////////////////////


def Dijkstra(G, num_nodes, start_node, arg):
    heap = [(0, start_node)]
    dist = [INF] * num_nodes
    dist[start_node] = 0
    flag = [False] * num_nodes
    cnt = 0

    for _ in range(INF):
        if len(heap) == 0:
            break
        popV = heappop(heap)
        if flag[popV[1]]:
            continue
        if popV[0] > X:
            break

        for i in G[popV[1]]:
            if i[2] < arg:
                continue
            dist[i[1]] = min(dist[i[1]], popV[0] + i[0])
            heappush(heap, (dist[i[1]], i[1]))
        flag[popV[1]] = True
        cnt += 1
        if cnt == num_nodes:
            break

    return dist[N - 1]


# 最大
def is_ok(arg):
    return Dijkstra(G, N, 0, arg) < X


def meguru_bisect(ng, ok):
    """
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    """
    for _ in range(10**18):
        if not abs(ng - ok) > 1:
            break
        mid = (ng + ok) // 2
        if is_ok(mid):
            ng = mid
        else:
            ok = mid
    return ng


N, M, X = map(int, input().split())
roads = [list(map(int, input().split())) for _ in range(M)]

G = defaultdict(set)

for u, v, a, b in roads:
    G[u - 1].add((a, v - 1, b))
    G[v - 1].add((a, u - 1, b))

print(meguru_bisect(-1, INF))
0