結果

問題 No.1473 おでぶなおばけさん
ユーザー FromBooskaFromBooska
提出日時 2023-02-14 20:46:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,836 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 291,692 KB
最終ジャッジ日時 2023-09-24 08:28:32
合計ジャッジ時間 33,837 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,628 KB
testcase_01 AC 97 ms
71,788 KB
testcase_02 AC 1,257 ms
236,892 KB
testcase_03 AC 794 ms
175,672 KB
testcase_04 AC 683 ms
140,588 KB
testcase_05 AC 259 ms
87,644 KB
testcase_06 AC 957 ms
178,888 KB
testcase_07 AC 1,492 ms
263,240 KB
testcase_08 AC 1,836 ms
291,692 KB
testcase_09 AC 1,383 ms
259,920 KB
testcase_10 AC 272 ms
91,084 KB
testcase_11 AC 242 ms
91,268 KB
testcase_12 AC 267 ms
91,308 KB
testcase_13 AC 201 ms
87,112 KB
testcase_14 AC 183 ms
84,720 KB
testcase_15 AC 261 ms
91,008 KB
testcase_16 AC 254 ms
90,860 KB
testcase_17 AC 142 ms
78,532 KB
testcase_18 AC 151 ms
79,620 KB
testcase_19 AC 263 ms
90,576 KB
testcase_20 AC 494 ms
123,424 KB
testcase_21 AC 401 ms
101,864 KB
testcase_22 AC 396 ms
115,632 KB
testcase_23 AC 321 ms
108,156 KB
testcase_24 AC 330 ms
104,600 KB
testcase_25 AC 1,404 ms
217,600 KB
testcase_26 AC 1,339 ms
201,116 KB
testcase_27 AC 404 ms
94,820 KB
testcase_28 AC 1,210 ms
206,340 KB
testcase_29 AC 580 ms
120,012 KB
testcase_30 AC 795 ms
139,696 KB
testcase_31 AC 1,029 ms
188,984 KB
testcase_32 AC 617 ms
141,880 KB
testcase_33 AC 525 ms
123,056 KB
testcase_34 AC 339 ms
97,416 KB
testcase_35 AC 264 ms
92,256 KB
testcase_36 AC 538 ms
113,372 KB
testcase_37 AC 857 ms
155,332 KB
testcase_38 AC 197 ms
81,220 KB
testcase_39 AC 244 ms
91,248 KB
testcase_40 AC 268 ms
91,004 KB
testcase_41 AC 260 ms
96,620 KB
testcase_42 AC 232 ms
96,616 KB
testcase_43 AC 417 ms
163,928 KB
testcase_44 AC 422 ms
164,172 KB
testcase_45 AC 422 ms
163,856 KB
testcase_46 AC 671 ms
153,936 KB
testcase_47 AC 982 ms
192,116 KB
testcase_48 AC 860 ms
180,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 体重決め打ちで二分探索、BFSでどうか

N, M = map(int, input().split())
edge_list = []
for i in range(M):
    s, t, d = map(int, input().split())
    edge_list.append((s, t, d))

from collections import deque
INF = 10**10

def BFS(weight):
    edges = [[] for i in range(N+1)]
    for s, t, d in edge_list:
        if d >= weight:
            edges[s].append(t)
            edges[t].append(s)
            
    que = deque()
    que.append(1)
    distance = [INF]*(N+1)
    distance[1] = 0
    while que:
        current = que.popleft()
        for nxt in edges[current]:
            if distance[nxt] > distance[current]+1:
                distance[nxt] = distance[current]+1
                que.append(nxt)
    #print(distance)
    return distance[N]
            
#for w in range(1, 5):
#    print(w, BFS(w))

OK = 0
NG = 10**9+1
while NG-OK>1:
    mid = (NG+OK)//2
    if BFS(mid) == INF:
        NG = mid
    else:
        OK = mid
print(OK, BFS(OK))
    
    
    

0