結果

問題 No.1473 おでぶなおばけさん
ユーザー lie_of_lillielie_of_lillie
提出日時 2021-05-14 16:00:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 762 ms / 2,000 ms
コード長 839 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 139,128 KB
最終ジャッジ日時 2024-04-09 20:17:37
合計ジャッジ時間 16,804 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
54,504 KB
testcase_01 AC 37 ms
54,848 KB
testcase_02 AC 544 ms
125,832 KB
testcase_03 AC 314 ms
116,832 KB
testcase_04 AC 373 ms
105,708 KB
testcase_05 AC 204 ms
82,072 KB
testcase_06 AC 543 ms
115,036 KB
testcase_07 AC 481 ms
131,096 KB
testcase_08 AC 762 ms
131,004 KB
testcase_09 AC 451 ms
131,976 KB
testcase_10 AC 184 ms
86,812 KB
testcase_11 AC 194 ms
86,904 KB
testcase_12 AC 170 ms
86,852 KB
testcase_13 AC 138 ms
83,140 KB
testcase_14 AC 134 ms
81,288 KB
testcase_15 AC 210 ms
85,608 KB
testcase_16 AC 191 ms
85,080 KB
testcase_17 AC 78 ms
77,216 KB
testcase_18 AC 81 ms
77,232 KB
testcase_19 AC 198 ms
85,252 KB
testcase_20 AC 289 ms
120,296 KB
testcase_21 AC 360 ms
100,936 KB
testcase_22 AC 276 ms
130,720 KB
testcase_23 AC 249 ms
129,572 KB
testcase_24 AC 255 ms
121,224 KB
testcase_25 AC 527 ms
112,372 KB
testcase_26 AC 557 ms
110,612 KB
testcase_27 AC 201 ms
83,768 KB
testcase_28 AC 654 ms
127,044 KB
testcase_29 AC 373 ms
101,864 KB
testcase_30 AC 517 ms
105,664 KB
testcase_31 AC 401 ms
139,128 KB
testcase_32 AC 412 ms
124,144 KB
testcase_33 AC 323 ms
114,892 KB
testcase_34 AC 226 ms
97,372 KB
testcase_35 AC 208 ms
92,652 KB
testcase_36 AC 360 ms
95,344 KB
testcase_37 AC 411 ms
110,760 KB
testcase_38 AC 145 ms
79,412 KB
testcase_39 AC 164 ms
85,532 KB
testcase_40 AC 167 ms
85,320 KB
testcase_41 AC 241 ms
87,536 KB
testcase_42 AC 230 ms
87,652 KB
testcase_43 AC 227 ms
99,504 KB
testcase_44 AC 226 ms
99,048 KB
testcase_45 AC 225 ms
99,372 KB
testcase_46 AC 277 ms
112,156 KB
testcase_47 AC 461 ms
120,824 KB
testcase_48 AC 422 ms
114,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import heapq
import math

N,M=map(int,input().split())

G = collections.defaultdict(list)

for _ in range(M):
    S,T,D = map(int, input().split())
    G[S-1].append((T-1,D))
    G[T-1].append((S-1,D))

def bfs(max_w):
    que = collections.deque([(0,0)]) # index, something val
    visited = [-1]*N
    while que:
        i, c = que.popleft() # queはFIFO
        if visited[i] >= 0:
            continue
        visited[i] = c
        for j, d in G[i]:
            if visited[j] == -1 and max_w <= d: # まだ未踏のノードであれば
                que.append((j,c+1)) # 自分の値に+1してqueに入れる
    return visited[-1]

ok = 0
ng = 1 << 64
while(True):
    mid = (ok+ng) // 2
    if bfs(mid) != -1:
        ok = mid
    else:
        ng = mid
    if ng - ok == 1:
        break
print(ok, bfs(ok))
0