結果

問題 No.1607 Kth Maximum Card
ユーザー tamatotamato
提出日時 2021-07-16 21:53:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,188 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 87,408 KB
実行使用メモリ 140,056 KB
最終ジャッジ日時 2023-09-20 13:43:17
合計ジャッジ時間 11,489 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 92 ms
72,104 KB
testcase_02 AC 92 ms
71,712 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 93 ms
71,984 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 398 ms
125,720 KB
testcase_10 AC 501 ms
140,056 KB
testcase_11 AC 164 ms
86,552 KB
testcase_12 AC 388 ms
122,480 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 165 ms
86,000 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 335 ms
113,176 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = 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