結果

問題 No.1473 おでぶなおばけさん
ユーザー ronpooronpoo
提出日時 2023-10-31 13:54:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,044 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 442,160 KB
最終ジャッジ日時 2023-10-31 13:54:38
合計ジャッジ時間 18,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
60,004 KB
testcase_01 AC 40 ms
55,656 KB
testcase_02 AC 465 ms
119,580 KB
testcase_03 AC 335 ms
117,356 KB
testcase_04 AC 247 ms
100,832 KB
testcase_05 AC 143 ms
82,572 KB
testcase_06 AC 456 ms
112,532 KB
testcase_07 AC 414 ms
124,784 KB
testcase_08 AC 544 ms
125,312 KB
testcase_09 AC 353 ms
124,772 KB
testcase_10 AC 193 ms
102,664 KB
testcase_11 AC 238 ms
99,492 KB
testcase_12 AC 187 ms
101,868 KB
testcase_13 AC 129 ms
90,860 KB
testcase_14 AC 107 ms
86,500 KB
testcase_15 AC 164 ms
96,636 KB
testcase_16 AC 182 ms
102,440 KB
testcase_17 AC 73 ms
77,676 KB
testcase_18 AC 83 ms
77,684 KB
testcase_19 AC 266 ms
98,608 KB
testcase_20 AC 330 ms
107,040 KB
testcase_21 AC 469 ms
104,540 KB
testcase_22 AC 498 ms
112,368 KB
testcase_23 AC 555 ms
107,192 KB
testcase_24 AC 508 ms
106,008 KB
testcase_25 AC 371 ms
111,432 KB
testcase_26 AC 229 ms
117,304 KB
testcase_27 AC 138 ms
86,616 KB
testcase_28 AC 309 ms
125,860 KB
testcase_29 AC 266 ms
108,204 KB
testcase_30 AC 297 ms
111,840 KB
testcase_31 AC 377 ms
121,712 KB
testcase_32 AC 469 ms
112,936 KB
testcase_33 AC 245 ms
111,188 KB
testcase_34 AC 144 ms
94,212 KB
testcase_35 AC 204 ms
94,316 KB
testcase_36 AC 436 ms
101,208 KB
testcase_37 AC 238 ms
112,188 KB
testcase_38 AC 83 ms
78,372 KB
testcase_39 AC 176 ms
102,712 KB
testcase_40 AC 186 ms
102,980 KB
testcase_41 AC 158 ms
108,680 KB
testcase_42 AC 159 ms
108,672 KB
testcase_43 AC 214 ms
111,108 KB
testcase_44 AC 218 ms
111,112 KB
testcase_45 AC 223 ms
111,112 KB
testcase_46 TLE -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
input = sys.stdin.readline

n, m = map(int, input().split())
std = [list(map(int, input().split())) for _ in range(m)]

G = [[] for _ in range(n)]
D = []
W = [float('inf')] * (m+2)
for i in range(m):
    s, t, d = std[i]
    s -= 1
    t -= 1
    G[s].append((t, d))
    G[t].append((s, d))
    D.append(d)

def bfs(cost):
    dist = [float('inf')] * n
    dist[0] = 0
    q = deque([0])
    while q:
        now = q.popleft()
        for nxt, d in G[now]:            
            if dist[nxt] < dist[now] + 1:
                continue
            if d < cost:
                continue
            dist[nxt] = dist[now] + 1
            if nxt == n-1:                
                return dist[nxt]
            q.append(nxt)
    return float('inf')

D.append(0)
D.append(float('inf'))
D.sort()
ok = 0
ng = len(D)
while ng - ok > 1:
    mid = (ng + ok) // 2
    W[mid] = bfs(D[mid])
    if W[mid] != float('inf'):
        ok = mid        
    else:
        ng = mid
                
print(D[ok], W[ok])
0