結果

問題 No.1473 おでぶなおばけさん
ユーザー 310icecrystal310icecrystal
提出日時 2023-07-06 05:02:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,124 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 147,740 KB
最終ジャッジ日時 2023-09-27 05:56:30
合計ジャッジ時間 25,129 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,612 KB
testcase_01 AC 82 ms
71,368 KB
testcase_02 AC 941 ms
133,284 KB
testcase_03 AC 460 ms
124,200 KB
testcase_04 AC 527 ms
109,808 KB
testcase_05 AC 267 ms
87,372 KB
testcase_06 AC 909 ms
123,508 KB
testcase_07 AC 780 ms
141,772 KB
testcase_08 AC 1,085 ms
142,212 KB
testcase_09 AC 547 ms
145,104 KB
testcase_10 AC 254 ms
92,388 KB
testcase_11 AC 286 ms
92,088 KB
testcase_12 AC 250 ms
92,560 KB
testcase_13 AC 197 ms
89,044 KB
testcase_14 AC 185 ms
84,660 KB
testcase_15 AC 255 ms
92,148 KB
testcase_16 AC 215 ms
89,196 KB
testcase_17 AC 121 ms
78,456 KB
testcase_18 AC 130 ms
79,324 KB
testcase_19 AC 285 ms
90,980 KB
testcase_20 AC 363 ms
125,592 KB
testcase_21 AC 498 ms
106,000 KB
testcase_22 AC 412 ms
136,712 KB
testcase_23 AC 361 ms
135,664 KB
testcase_24 AC 316 ms
126,724 KB
testcase_25 AC 775 ms
117,912 KB
testcase_26 AC 956 ms
118,436 KB
testcase_27 AC 252 ms
86,248 KB
testcase_28 AC 1,124 ms
135,408 KB
testcase_29 AC 551 ms
104,676 KB
testcase_30 AC 608 ms
110,592 KB
testcase_31 AC 630 ms
147,740 KB
testcase_32 AC 575 ms
131,136 KB
testcase_33 AC 446 ms
121,236 KB
testcase_34 AC 261 ms
103,080 KB
testcase_35 AC 280 ms
98,616 KB
testcase_36 AC 416 ms
101,608 KB
testcase_37 AC 635 ms
117,048 KB
testcase_38 AC 179 ms
82,284 KB
testcase_39 AC 222 ms
89,112 KB
testcase_40 AC 214 ms
88,952 KB
testcase_41 AC 290 ms
96,660 KB
testcase_42 AC 280 ms
96,676 KB
testcase_43 AC 312 ms
124,256 KB
testcase_44 AC 316 ms
124,312 KB
testcase_45 AC 333 ms
124,276 KB
testcase_46 AC 367 ms
117,592 KB
testcase_47 AC 440 ms
129,440 KB
testcase_48 AC 506 ms
126,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
graph = [set() for _ in range(n+1)]
for _ in range(m):
    s,t,d = map(int,input().split())
    graph[s].add((t,d))
    graph[t].add((s,d))

from collections import deque
def bfs(G,start,w):
    Deq = deque()
    dist = [-1] * (n + 1)
    Deq.append(start)
    dist[start] = 0
    while Deq :
        pos = Deq.popleft()
        for nex,d in G[pos] :
            if dist[nex] == -1 and w <= d:
                dist[nex] = dist[pos] + 1
                Deq.append(nex)
    return dist

OK = 0
NG = 10**18
while NG - OK >= 2:
    MID = (OK+NG)//2
    dist_MID = bfs(graph,1,MID)
    if dist_MID[n] != -1:
        OK = MID
    else:
        NG = MID

dist_OK = bfs(graph,1,OK)
print(OK,dist_OK[n])
0