結果

問題 No.1607 Kth Maximum Card
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-08-14 13:04:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,669 ms / 3,500 ms
コード長 788 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 144,420 KB
最終ジャッジ日時 2024-04-15 10:45:55
合計ジャッジ時間 31,588 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,760 KB
testcase_01 AC 46 ms
53,760 KB
testcase_02 AC 44 ms
54,272 KB
testcase_03 AC 43 ms
53,888 KB
testcase_04 AC 44 ms
53,888 KB
testcase_05 AC 43 ms
53,760 KB
testcase_06 AC 43 ms
54,016 KB
testcase_07 AC 43 ms
53,888 KB
testcase_08 AC 2,232 ms
130,728 KB
testcase_09 AC 2,155 ms
125,248 KB
testcase_10 AC 2,669 ms
144,420 KB
testcase_11 AC 536 ms
87,808 KB
testcase_12 AC 2,046 ms
121,184 KB
testcase_13 AC 296 ms
84,252 KB
testcase_14 AC 341 ms
86,400 KB
testcase_15 AC 1,399 ms
118,852 KB
testcase_16 AC 264 ms
84,700 KB
testcase_17 AC 167 ms
79,232 KB
testcase_18 AC 906 ms
102,108 KB
testcase_19 AC 543 ms
91,736 KB
testcase_20 AC 727 ms
94,980 KB
testcase_21 AC 766 ms
96,988 KB
testcase_22 AC 1,387 ms
127,844 KB
testcase_23 AC 1,367 ms
129,116 KB
testcase_24 AC 822 ms
91,760 KB
testcase_25 AC 514 ms
86,528 KB
testcase_26 AC 612 ms
88,320 KB
testcase_27 AC 859 ms
92,712 KB
testcase_28 AC 718 ms
90,284 KB
testcase_29 AC 1,453 ms
105,716 KB
testcase_30 AC 2,489 ms
130,076 KB
testcase_31 AC 1,355 ms
103,612 KB
testcase_32 AC 456 ms
99,840 KB
testcase_33 AC 454 ms
100,160 KB
testcase_34 AC 447 ms
99,984 KB
testcase_35 AC 458 ms
99,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


n, m, k = map(int, input().split())
G = [[] for i in range(n)]
for _ in range(m):
    u, v, c = map(int, input().split())
    u -= 1; v -= 1
    G[u].append((v, c))
    G[v].append((u, c))
def ok(x):
    Q = deque([0])
    d = [-1] * n
    d[0] = 0
    while Q:
        u = Q.popleft()
        for v, c in G[u]:
            if c > x:
                if d[v] == -1 or (d[u] != -1 and d[v] > d[u] + 1):
                    d[v] = d[u] + 1
                    Q.append(v)
            else:
                if d[v] == -1 or (d[u] != -1 and d[v] > d[u]):
                    d[v] = d[u]
                    Q.appendleft(v)
    return d[-1] < k
l, r = -1, 10 ** 6
while r - l > 1:
    M = (l + r) // 2
    if ok(M):
        r = M
    else:
        l = M
print(r)
0