結果

問題 No.1473 おでぶなおばけさん
ユーザー roarisroaris
提出日時 2021-04-09 22:36:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 895 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 114,588 KB
最終ジャッジ日時 2023-09-07 12:10:01
合計ジャッジ時間 19,963 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,460 KB
testcase_01 AC 91 ms
71,768 KB
testcase_02 AC 703 ms
102,668 KB
testcase_03 AC 363 ms
101,912 KB
testcase_04 AC 497 ms
91,660 KB
testcase_05 AC 222 ms
81,420 KB
testcase_06 AC 718 ms
97,500 KB
testcase_07 AC 649 ms
105,672 KB
testcase_08 AC 895 ms
105,280 KB
testcase_09 AC 615 ms
107,860 KB
testcase_10 AC 188 ms
85,896 KB
testcase_11 AC 190 ms
85,664 KB
testcase_12 AC 179 ms
85,868 KB
testcase_13 AC 149 ms
82,144 KB
testcase_14 AC 135 ms
79,476 KB
testcase_15 AC 174 ms
81,960 KB
testcase_16 AC 163 ms
84,732 KB
testcase_17 AC 113 ms
77,396 KB
testcase_18 AC 116 ms
77,680 KB
testcase_19 AC 253 ms
85,552 KB
testcase_20 AC 331 ms
102,960 KB
testcase_21 AC 386 ms
95,432 KB
testcase_22 AC 315 ms
108,812 KB
testcase_23 AC 288 ms
109,224 KB
testcase_24 AC 271 ms
105,040 KB
testcase_25 AC 885 ms
97,816 KB
testcase_26 AC 650 ms
97,652 KB
testcase_27 AC 228 ms
82,640 KB
testcase_28 AC 757 ms
105,988 KB
testcase_29 AC 531 ms
93,280 KB
testcase_30 AC 630 ms
96,160 KB
testcase_31 AC 581 ms
114,588 KB
testcase_32 AC 500 ms
107,028 KB
testcase_33 AC 428 ms
98,624 KB
testcase_34 AC 280 ms
90,440 KB
testcase_35 AC 240 ms
87,692 KB
testcase_36 AC 402 ms
89,832 KB
testcase_37 AC 553 ms
96,508 KB
testcase_38 AC 157 ms
79,860 KB
testcase_39 AC 169 ms
84,700 KB
testcase_40 AC 157 ms
84,544 KB
testcase_41 AC 167 ms
87,836 KB
testcase_42 AC 164 ms
87,608 KB
testcase_43 AC 211 ms
98,792 KB
testcase_44 AC 210 ms
98,720 KB
testcase_45 AC 212 ms
98,676 KB
testcase_46 AC 332 ms
99,408 KB
testcase_47 AC 324 ms
100,224 KB
testcase_48 AC 373 ms
99,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def bfs(x):
    dist = [-1]*n
    dist[0] = 0
    q = deque([0])
    
    while q:
        v = q.popleft()
        
        for nv, d in G[v]:
            if x<=d and dist[nv]==-1:
                dist[nv] = dist[v]+1
                q.append(nv)
    
    return dist[-1]

def binary_search():
    l, r = 0, 10**10
    
    while l<=r:
        m = (l+r)//2
        
        if bfs(m)>=0:
            l = m+1
        else:
            r = m-1
    
    return r

n, m = map(int, input().split())
G = [[] for _ in range(n)]

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

w = binary_search()
print(w, bfs(w))
0