結果

問題 No.1607 Kth Maximum Card
ユーザー tamatotamato
提出日時 2021-07-16 21:51:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,190 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 76,248 KB
最終ジャッジ日時 2023-09-20 13:39:24
合計ジャッジ時間 7,421 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
76,248 KB
testcase_01 AC 92 ms
71,996 KB
testcase_02 AC 93 ms
71,836 KB
testcase_03 AC 97 ms
71,908 KB
testcase_04 AC 95 ms
71,860 KB
testcase_05 AC 95 ms
71,812 KB
testcase_06 AC 94 ms
71,832 KB
testcase_07 AC 95 ms
71,860 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
L = 2*10**5


def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    N, M, K = map(int, input().split())
    ABC = []
    for _ in range(M):
        ABC.append(tuple(map(int, input().split())))

    ok = L+1
    ng = -1
    mid = (ok + ng) // 2
    while ok - ng > 1:
        adj = [[] for _ in range(N+1)]
        for a, b, c in ABC:
            if c > mid:
                adj[a].append((b, 1))
                adj[b].append((a, 1))
            else:
                adj[a].append((b, 0))
                adj[b].append((a, 0))

        que = deque()
        que.append((1, 0))
        seen = [-1] * (N+1)
        while que:
            v, d = que.popleft()
            if seen[v] != -1:
                continue
            seen[v] = d
            for u, c in adj[v]:
                if seen[u] == -1:
                    if c:
                        que.append((u, d+1))
                    else:
                        que.appendleft((u, d))
        if seen[N] < K:
            ok = mid
        else:
            ng = mid
        mid = (ok + ng) // 2
    print(ok)


if __name__ == '__main__':
    main()
0