結果

問題 No.1473 おでぶなおばけさん
ユーザー lloyzlloyz
提出日時 2022-08-11 22:25:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,325 ms / 2,000 ms
コード長 1,280 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 81,644 KB
実行使用メモリ 174,676 KB
最終ジャッジ日時 2023-10-22 03:58:08
合計ジャッジ時間 20,233 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,584 KB
testcase_01 AC 41 ms
55,584 KB
testcase_02 AC 945 ms
160,156 KB
testcase_03 AC 448 ms
109,724 KB
testcase_04 AC 532 ms
122,264 KB
testcase_05 AC 224 ms
89,220 KB
testcase_06 AC 817 ms
130,360 KB
testcase_07 AC 826 ms
148,268 KB
testcase_08 AC 1,325 ms
174,676 KB
testcase_09 AC 632 ms
133,104 KB
testcase_10 AC 145 ms
83,264 KB
testcase_11 AC 169 ms
83,196 KB
testcase_12 AC 144 ms
83,292 KB
testcase_13 AC 119 ms
79,784 KB
testcase_14 AC 101 ms
79,520 KB
testcase_15 AC 138 ms
83,016 KB
testcase_16 AC 139 ms
82,496 KB
testcase_17 AC 80 ms
76,752 KB
testcase_18 AC 84 ms
77,128 KB
testcase_19 AC 197 ms
85,408 KB
testcase_20 AC 413 ms
108,784 KB
testcase_21 AC 450 ms
114,220 KB
testcase_22 AC 235 ms
114,812 KB
testcase_23 AC 214 ms
112,372 KB
testcase_24 AC 213 ms
104,088 KB
testcase_25 AC 1,128 ms
158,668 KB
testcase_26 AC 470 ms
119,292 KB
testcase_27 AC 260 ms
88,176 KB
testcase_28 AC 624 ms
142,588 KB
testcase_29 AC 480 ms
126,980 KB
testcase_30 AC 762 ms
150,888 KB
testcase_31 AC 587 ms
134,356 KB
testcase_32 AC 482 ms
120,652 KB
testcase_33 AC 330 ms
110,440 KB
testcase_34 AC 167 ms
89,072 KB
testcase_35 AC 203 ms
92,488 KB
testcase_36 AC 517 ms
118,468 KB
testcase_37 AC 317 ms
110,948 KB
testcase_38 AC 97 ms
78,008 KB
testcase_39 AC 131 ms
82,532 KB
testcase_40 AC 133 ms
82,464 KB
testcase_41 AC 129 ms
86,092 KB
testcase_42 AC 127 ms
86,084 KB
testcase_43 AC 246 ms
136,988 KB
testcase_44 AC 241 ms
136,988 KB
testcase_45 AC 244 ms
136,984 KB
testcase_46 AC 402 ms
132,072 KB
testcase_47 AC 493 ms
142,864 KB
testcase_48 AC 507 ms
143,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.readline
INF = 1 << 30

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    s, t, d = map(int, input().split())
    s -= 1
    t -= 1
    edge[s].append((t, d))
    edge[t].append((s, d))

left, right = 1, 10**9 + 10
while right - left > 1:
    mid = (left + right) // 2
    Que = deque([0])
    seen = set([0])
    C = [INF] * n
    C[0] = 0
    while Que:
        cp = Que.popleft()
        if cp == n - 1:
            break
        cnt = C[cp]
        for np, w in edge[cp]:
            if w < mid:
                continue
            if cnt + 1 > C[np]:
                continue
            if np in seen:
                continue
            seen.add(np)
            C[np] = cnt + 1
            Que.append(np)
    if C[n - 1] < INF:
        left = mid
    else:
        right = mid

Que = deque([0])
seen = set([0])
C = [INF] * n
C[0] = 0
while Que:
    cp = Que.popleft()
    if cp == n - 1:
        print(left, C[cp])
        break
    cnt = C[cp]
    for np, w in edge[cp]:
        if w < left:
            continue
        if cnt + 1 > C[np]:
            continue
        if np in seen:
            continue
        seen.add(np)
        C[np] = cnt + 1
        Que.append(np)

0