結果

問題 No.1473 おでぶなおばけさん
ユーザー DrDrpilotDrDrpilot
提出日時 2022-05-08 16:18:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 837 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 132,464 KB
最終ジャッジ日時 2023-09-22 12:56:37
合計ジャッジ時間 23,424 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,708 KB
testcase_01 AC 95 ms
71,560 KB
testcase_02 AC 745 ms
126,452 KB
testcase_03 AC 469 ms
118,992 KB
testcase_04 AC 473 ms
106,096 KB
testcase_05 AC 228 ms
86,476 KB
testcase_06 AC 837 ms
121,240 KB
testcase_07 AC 598 ms
131,756 KB
testcase_08 AC 802 ms
132,464 KB
testcase_09 AC 534 ms
131,744 KB
testcase_10 AC 317 ms
117,656 KB
testcase_11 AC 325 ms
117,244 KB
testcase_12 AC 316 ms
117,444 KB
testcase_13 AC 247 ms
101,660 KB
testcase_14 AC 199 ms
93,668 KB
testcase_15 AC 303 ms
113,000 KB
testcase_16 AC 301 ms
115,068 KB
testcase_17 AC 136 ms
77,776 KB
testcase_18 AC 145 ms
81,120 KB
testcase_19 AC 355 ms
97,320 KB
testcase_20 AC 423 ms
105,504 KB
testcase_21 AC 513 ms
104,144 KB
testcase_22 AC 389 ms
104,316 KB
testcase_23 AC 346 ms
101,488 KB
testcase_24 AC 362 ms
100,880 KB
testcase_25 AC 385 ms
104,104 KB
testcase_26 AC 400 ms
105,352 KB
testcase_27 AC 209 ms
86,916 KB
testcase_28 AC 367 ms
110,956 KB
testcase_29 AC 358 ms
101,736 KB
testcase_30 AC 414 ms
105,808 KB
testcase_31 AC 664 ms
128,624 KB
testcase_32 AC 755 ms
123,584 KB
testcase_33 AC 457 ms
114,404 KB
testcase_34 AC 313 ms
96,488 KB
testcase_35 AC 305 ms
102,616 KB
testcase_36 AC 318 ms
97,264 KB
testcase_37 AC 318 ms
99,680 KB
testcase_38 AC 164 ms
80,612 KB
testcase_39 AC 288 ms
115,516 KB
testcase_40 AC 275 ms
115,584 KB
testcase_41 AC 292 ms
114,968 KB
testcase_42 AC 268 ms
114,772 KB
testcase_43 AC 273 ms
121,428 KB
testcase_44 AC 272 ms
121,548 KB
testcase_45 AC 270 ms
121,972 KB
testcase_46 AC 325 ms
116,576 KB
testcase_47 AC 378 ms
128,036 KB
testcase_48 AC 366 ms
124,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n,m=map(int,input().split())
g=[[] for _ in range(n)]
W=[]
for _ in range(m):
    s,t,d=map(int,input().split())
    s-=1;t-=1
    W.append(d)
    g[s].append([t,d])
    g[t].append([s,d])
def bfs(w):
    dst=[-1]*n 
    dst[0]=0
    q=deque()
    q.append(0)
    while q:
        now=q.popleft()
        for to,limit in g[now]:
            if limit<w:
                continue
            if dst[to]!=-1:
                continue
            dst[to]=dst[now]+1
            q.append(to)
    return dst[-1]
W=list(set(W))
W.sort()
ng=len(W)
ok=-1
while ng-ok>1:
    mid=(ok+ng)//2
    if bfs(W[mid])!=-1:
        ok=mid
    else:
        ng=mid
print(W[ok],bfs(W[ok]))
0