結果

問題 No.1473 おでぶなおばけさん
ユーザー O2MTO2MT
提出日時 2021-06-02 00:53:09
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,188 bytes
コンパイル時間 2,573 ms
コンパイル使用メモリ 86,056 KB
実行使用メモリ 126,140 KB
最終ジャッジ日時 2023-08-08 17:24:09
合計ジャッジ時間 26,649 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,600 KB
testcase_01 AC 89 ms
71,280 KB
testcase_02 AC 674 ms
110,848 KB
testcase_03 AC 465 ms
107,548 KB
testcase_04 AC 483 ms
93,920 KB
testcase_05 AC 228 ms
81,220 KB
testcase_06 AC 666 ms
102,156 KB
testcase_07 AC 567 ms
107,364 KB
testcase_08 AC 908 ms
108,056 KB
testcase_09 AC 581 ms
110,420 KB
testcase_10 AC 247 ms
86,144 KB
testcase_11 AC 268 ms
85,884 KB
testcase_12 AC 220 ms
86,212 KB
testcase_13 AC 203 ms
83,372 KB
testcase_14 AC 165 ms
80,588 KB
testcase_15 AC 248 ms
85,940 KB
testcase_16 AC 206 ms
84,944 KB
testcase_17 AC 132 ms
78,096 KB
testcase_18 AC 139 ms
78,700 KB
testcase_19 AC 256 ms
86,056 KB
testcase_20 AC 361 ms
109,648 KB
testcase_21 AC 422 ms
99,192 KB
testcase_22 AC 313 ms
123,744 KB
testcase_23 AC 292 ms
124,084 KB
testcase_24 AC 284 ms
116,780 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 768 ms
111,412 KB
testcase_29 AC 501 ms
97,872 KB
testcase_30 AC 635 ms
100,652 KB
testcase_31 AC 593 ms
126,140 KB
testcase_32 AC 507 ms
110,968 KB
testcase_33 AC 416 ms
104,464 KB
testcase_34 AC 270 ms
95,248 KB
testcase_35 AC 239 ms
91,304 KB
testcase_36 AC 341 ms
92,896 KB
testcase_37 AC 594 ms
101,072 KB
testcase_38 AC 163 ms
80,068 KB
testcase_39 AC 204 ms
84,828 KB
testcase_40 AC 202 ms
84,712 KB
testcase_41 AC 255 ms
88,252 KB
testcase_42 AC 209 ms
88,296 KB
testcase_43 AC 254 ms
106,608 KB
testcase_44 AC 259 ms
106,052 KB
testcase_45 AC 257 ms
106,056 KB
testcase_46 AC 345 ms
108,944 KB
testcase_47 AC 410 ms
104,140 KB
testcase_48 AC 385 ms
104,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def is_ok(w):
    # 条件を満たすかどうか?問題ごとに定義
    que = deque([(0,0)])
    visited = [float('inf')]*N
    visited[0] = 0
    while que:
      t,c = que.popleft()
      for i,j in l[t]:
        if w > j or c+1 >= visited[i]:
          continue
        visited[i] = c+1
        que.append((i,c+1))
    if visited[-1] == float('inf'):
      visited[-1] = -1
    return visited[-1]



def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    num = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        flg = is_ok(mid)
        if flg != -1:
            ng = mid
            num = flg
        else:
            ok = mid
    return (ng,num)

N,M = map(int,input().split())
l = [[] for _ in range(N)]

for _ in range(M):
  a,b,c = map(int,input().split())
  a -= 1
  b -= 1
  l[a].append((b,c))
  l[b].append((a,c))
ng,ok = 0,10**9
ans = meguru_bisect(ng,ok)

print(ans[0],ans[1])
0