結果

問題 No.1473 おでぶなおばけさん
ユーザー lloyzlloyz
提出日時 2022-08-11 22:27:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 918 ms / 2,000 ms
コード長 1,103 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 113,076 KB
最終ジャッジ日時 2023-10-22 03:59:36
合計ジャッジ時間 15,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,696 KB
testcase_01 AC 42 ms
55,696 KB
testcase_02 AC 649 ms
105,072 KB
testcase_03 AC 321 ms
100,380 KB
testcase_04 AC 343 ms
92,868 KB
testcase_05 AC 167 ms
79,808 KB
testcase_06 AC 552 ms
100,984 KB
testcase_07 AC 577 ms
104,928 KB
testcase_08 AC 918 ms
102,440 KB
testcase_09 AC 481 ms
107,912 KB
testcase_10 AC 139 ms
83,320 KB
testcase_11 AC 152 ms
83,236 KB
testcase_12 AC 129 ms
83,356 KB
testcase_13 AC 106 ms
79,848 KB
testcase_14 AC 90 ms
79,512 KB
testcase_15 AC 131 ms
83,036 KB
testcase_16 AC 121 ms
82,540 KB
testcase_17 AC 65 ms
73,104 KB
testcase_18 AC 76 ms
77,060 KB
testcase_19 AC 173 ms
84,116 KB
testcase_20 AC 294 ms
97,624 KB
testcase_21 AC 304 ms
92,576 KB
testcase_22 AC 207 ms
105,908 KB
testcase_23 AC 173 ms
103,352 KB
testcase_24 AC 176 ms
99,548 KB
testcase_25 AC 682 ms
98,704 KB
testcase_26 AC 296 ms
101,516 KB
testcase_27 AC 182 ms
81,416 KB
testcase_28 AC 449 ms
113,076 KB
testcase_29 AC 325 ms
93,976 KB
testcase_30 AC 509 ms
96,932 KB
testcase_31 AC 425 ms
108,724 KB
testcase_32 AC 363 ms
101,920 KB
testcase_33 AC 248 ms
95,200 KB
testcase_34 AC 147 ms
86,832 KB
testcase_35 AC 170 ms
87,956 KB
testcase_36 AC 343 ms
90,888 KB
testcase_37 AC 247 ms
102,852 KB
testcase_38 AC 84 ms
78,056 KB
testcase_39 AC 126 ms
82,532 KB
testcase_40 AC 133 ms
82,532 KB
testcase_41 AC 119 ms
86,176 KB
testcase_42 AC 115 ms
86,164 KB
testcase_43 AC 176 ms
96,508 KB
testcase_44 AC 181 ms
96,508 KB
testcase_45 AC 173 ms
96,512 KB
testcase_46 AC 253 ms
95,700 KB
testcase_47 AC 328 ms
101,072 KB
testcase_48 AC 327 ms
98,392 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])
    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
            C[np] = cnt + 1
            Que.append(np)
    if C[n - 1] < INF:
        left = mid
    else:
        right = mid

Que = deque([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
        C[np] = cnt + 1
        Que.append(np)
0