結果

問題 No.1473 おでぶなおばけさん
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2021-11-28 19:11:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,295 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 2,723 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 119,048 KB
最終ジャッジ日時 2023-09-14 06:37:17
合計ジャッジ時間 26,907 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,804 KB
testcase_01 AC 87 ms
71,688 KB
testcase_02 AC 893 ms
112,168 KB
testcase_03 AC 494 ms
106,860 KB
testcase_04 AC 662 ms
101,988 KB
testcase_05 AC 268 ms
83,728 KB
testcase_06 AC 883 ms
107,132 KB
testcase_07 AC 820 ms
112,600 KB
testcase_08 AC 1,295 ms
118,760 KB
testcase_09 AC 652 ms
113,856 KB
testcase_10 AC 243 ms
86,116 KB
testcase_11 AC 246 ms
86,160 KB
testcase_12 AC 219 ms
86,544 KB
testcase_13 AC 177 ms
83,228 KB
testcase_14 AC 165 ms
80,604 KB
testcase_15 AC 232 ms
86,052 KB
testcase_16 AC 207 ms
85,156 KB
testcase_17 AC 122 ms
77,900 KB
testcase_18 AC 129 ms
78,124 KB
testcase_19 AC 299 ms
86,520 KB
testcase_20 AC 396 ms
105,232 KB
testcase_21 AC 550 ms
94,808 KB
testcase_22 AC 381 ms
115,272 KB
testcase_23 AC 330 ms
114,236 KB
testcase_24 AC 342 ms
108,392 KB
testcase_25 AC 1,141 ms
110,588 KB
testcase_26 AC 1,114 ms
107,584 KB
testcase_27 AC 248 ms
83,260 KB
testcase_28 AC 1,007 ms
117,388 KB
testcase_29 AC 613 ms
98,656 KB
testcase_30 AC 806 ms
103,880 KB
testcase_31 AC 663 ms
119,048 KB
testcase_32 AC 624 ms
109,988 KB
testcase_33 AC 497 ms
102,408 KB
testcase_34 AC 307 ms
91,720 KB
testcase_35 AC 290 ms
88,428 KB
testcase_36 AC 588 ms
92,908 KB
testcase_37 AC 678 ms
104,628 KB
testcase_38 AC 195 ms
80,180 KB
testcase_39 AC 231 ms
85,024 KB
testcase_40 AC 222 ms
84,720 KB
testcase_41 AC 229 ms
88,056 KB
testcase_42 AC 238 ms
88,320 KB
testcase_43 AC 280 ms
102,792 KB
testcase_44 AC 283 ms
102,512 KB
testcase_45 AC 284 ms
102,572 KB
testcase_46 AC 536 ms
103,452 KB
testcase_47 AC 547 ms
107,940 KB
testcase_48 AC 637 ms
103,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict,deque
import sys
sys.setrecursionlimit(10**6)

N,M = map(int,input().split())
e = defaultdict(list)
for _ in range(M):
    s,t,d = map(int,input().split())
    s -= 1
    t -= 1
    e[s].append((d,t))
    e[t].append((d,s))
    
v = deque()

def is_ok(x):
    dist = [-1]*N
    dist[0] = 0
    v.append(0)
    while v:
        ix = v.popleft()
        
        for d,jx in e[ix]:
            if dist[jx] != -1:
                continue
            if d>=x:
                dist[jx] = dist[ix] + 1
                v.append(jx)
    if dist[N-1] == -1:
        return False
    else:
        return dist[N-1]
        
x = 0
y = 10**10
while y-x>1:
    mid = (y+x)//2
    if is_ok(mid):
        x = mid
    else:
        y = mid
print(x,is_ok(x))
0