結果

問題 No.1473 おでぶなおばけさん
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2021-11-28 19:11:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,186 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,132 KB
実行使用メモリ 121,344 KB
最終ジャッジ日時 2024-07-01 14:05:47
合計ジャッジ時間 21,377 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
54,144 KB
testcase_01 AC 42 ms
53,632 KB
testcase_02 AC 884 ms
111,104 KB
testcase_03 AC 430 ms
109,188 KB
testcase_04 AC 590 ms
99,968 KB
testcase_05 AC 221 ms
81,908 KB
testcase_06 AC 784 ms
105,600 KB
testcase_07 AC 774 ms
112,384 KB
testcase_08 AC 1,186 ms
121,344 KB
testcase_09 AC 595 ms
113,152 KB
testcase_10 AC 224 ms
84,080 KB
testcase_11 AC 227 ms
83,456 KB
testcase_12 AC 191 ms
84,068 KB
testcase_13 AC 148 ms
80,384 KB
testcase_14 AC 130 ms
78,920 KB
testcase_15 AC 197 ms
83,456 KB
testcase_16 AC 174 ms
82,776 KB
testcase_17 AC 87 ms
76,800 KB
testcase_18 AC 89 ms
77,148 KB
testcase_19 AC 273 ms
84,608 KB
testcase_20 AC 340 ms
103,040 KB
testcase_21 AC 487 ms
93,440 KB
testcase_22 AC 339 ms
113,112 KB
testcase_23 AC 301 ms
111,404 KB
testcase_24 AC 286 ms
105,984 KB
testcase_25 AC 966 ms
107,032 KB
testcase_26 AC 922 ms
104,988 KB
testcase_27 AC 197 ms
81,280 KB
testcase_28 AC 888 ms
116,168 KB
testcase_29 AC 502 ms
95,280 KB
testcase_30 AC 683 ms
99,968 KB
testcase_31 AC 587 ms
116,096 KB
testcase_32 AC 538 ms
106,684 KB
testcase_33 AC 421 ms
99,584 KB
testcase_34 AC 249 ms
89,088 KB
testcase_35 AC 240 ms
86,884 KB
testcase_36 AC 473 ms
91,624 KB
testcase_37 AC 555 ms
102,360 KB
testcase_38 AC 151 ms
78,936 KB
testcase_39 AC 193 ms
82,816 KB
testcase_40 AC 172 ms
82,620 KB
testcase_41 AC 180 ms
87,808 KB
testcase_42 AC 196 ms
88,260 KB
testcase_43 AC 240 ms
101,632 KB
testcase_44 AC 238 ms
101,444 KB
testcase_45 AC 239 ms
101,592 KB
testcase_46 AC 449 ms
101,632 KB
testcase_47 AC 470 ms
104,472 KB
testcase_48 AC 514 ms
97,560 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