結果

問題 No.1473 おでぶなおばけさん
ユーザー titiatitia
提出日時 2022-02-11 02:29:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,113 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 117,616 KB
最終ジャッジ日時 2023-09-08 17:31:16
合計ジャッジ時間 21,511 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,512 KB
testcase_01 AC 91 ms
71,432 KB
testcase_02 AC 792 ms
105,156 KB
testcase_03 AC 409 ms
108,972 KB
testcase_04 AC 560 ms
94,220 KB
testcase_05 AC 233 ms
81,428 KB
testcase_06 AC 732 ms
102,200 KB
testcase_07 AC 641 ms
109,432 KB
testcase_08 AC 1,113 ms
106,208 KB
testcase_09 AC 610 ms
110,796 KB
testcase_10 AC 195 ms
85,704 KB
testcase_11 AC 207 ms
85,888 KB
testcase_12 AC 213 ms
86,020 KB
testcase_13 AC 169 ms
82,104 KB
testcase_14 AC 149 ms
79,500 KB
testcase_15 AC 189 ms
85,028 KB
testcase_16 AC 178 ms
84,280 KB
testcase_17 AC 118 ms
77,628 KB
testcase_18 AC 121 ms
77,392 KB
testcase_19 AC 238 ms
84,776 KB
testcase_20 AC 366 ms
99,912 KB
testcase_21 AC 409 ms
92,524 KB
testcase_22 AC 270 ms
108,144 KB
testcase_23 AC 233 ms
106,540 KB
testcase_24 AC 239 ms
102,636 KB
testcase_25 AC 683 ms
103,960 KB
testcase_26 AC 712 ms
106,340 KB
testcase_27 AC 236 ms
82,572 KB
testcase_28 AC 780 ms
107,636 KB
testcase_29 AC 480 ms
99,684 KB
testcase_30 AC 711 ms
100,516 KB
testcase_31 AC 474 ms
117,616 KB
testcase_32 AC 506 ms
110,588 KB
testcase_33 AC 413 ms
97,256 KB
testcase_34 AC 297 ms
89,820 KB
testcase_35 AC 233 ms
87,652 KB
testcase_36 AC 354 ms
92,164 KB
testcase_37 AC 566 ms
100,256 KB
testcase_38 AC 168 ms
79,540 KB
testcase_39 AC 176 ms
84,748 KB
testcase_40 AC 173 ms
84,472 KB
testcase_41 AC 180 ms
87,576 KB
testcase_42 AC 181 ms
87,568 KB
testcase_43 AC 239 ms
116,504 KB
testcase_44 AC 239 ms
116,964 KB
testcase_45 AC 238 ms
116,844 KB
testcase_46 AC 281 ms
102,508 KB
testcase_47 AC 390 ms
98,956 KB
testcase_48 AC 386 ms
99,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import deque

n,m=map(int,input().split())
E=[[] for i in range(n+1)]

for i in range(m):
    s,t,d=map(int,input().split())
    E[s].append((t,d))
    E[t].append((s,d))


OK=1
NG=1<<31

while NG-OK>1:
    mid=(OK+NG)//2

    GO=[0]*(n+1)
    GO[1]=1
    Q=[1]

    while Q:
        x=Q.pop()
        for to,d in E[x]:
            if d>=mid and GO[to]==0:
                GO[to]=1
                Q.append(to)

    if GO[n]==1:
        OK=mid
    else:
        NG=mid

X=[-1]*(n+1)
X[1]=0
Q=deque([1])

while Q:
    x=Q.popleft()
    
    for to,d in E[x]:
        if d>=OK and X[to]==-1:
            X[to]=X[x]+1
            Q.append(to)

print(OK,X[n])
                
0