結果

問題 No.1607 Kth Maximum Card
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-23 14:54:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,311 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 86,824 KB
実行使用メモリ 351,596 KB
最終ジャッジ日時 2023-08-19 19:50:55
合計ジャッジ時間 45,975 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,752 KB
testcase_01 AC 90 ms
71,744 KB
testcase_02 AC 89 ms
71,720 KB
testcase_03 AC 90 ms
71,580 KB
testcase_04 AC 90 ms
71,880 KB
testcase_05 AC 91 ms
71,692 KB
testcase_06 AC 89 ms
71,552 KB
testcase_07 AC 90 ms
71,912 KB
testcase_08 TLE -
testcase_09 AC 2,940 ms
339,924 KB
testcase_10 TLE -
testcase_11 AC 397 ms
135,956 KB
testcase_12 AC 2,836 ms
313,616 KB
testcase_13 AC 333 ms
109,576 KB
testcase_14 AC 374 ms
120,928 KB
testcase_15 AC 2,393 ms
335,660 KB
testcase_16 AC 346 ms
118,112 KB
testcase_17 AC 178 ms
83,460 KB
testcase_18 AC 1,328 ms
293,244 KB
testcase_19 AC 683 ms
185,024 KB
testcase_20 AC 1,140 ms
288,084 KB
testcase_21 AC 1,260 ms
301,240 KB
testcase_22 AC 2,975 ms
326,348 KB
testcase_23 AC 3,085 ms
351,596 KB
testcase_24 AC 1,004 ms
215,720 KB
testcase_25 AC 470 ms
130,692 KB
testcase_26 AC 642 ms
157,128 KB
testcase_27 AC 1,037 ms
227,820 KB
testcase_28 AC 826 ms
185,680 KB
testcase_29 AC 2,269 ms
293,196 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

from collections import deque
INF = 10**18

def main():
    n, m, k = map(int, input().split())
    E = []
    for i in range(m):
        u, v, c = map(int, input().split())
        u, v = u-1, v-1
        E.append((u, v, c))


    def bfs(s, edge):
        q = deque([])
        q.append(0)
        dist = [INF]*n
        dist[0] = 0
        while q:
            v = q.popleft()
            if v == n-1:
                return dist[n-1]
            for c, nv in edge[v]:
                if dist[v]+c < dist[nv]:
                    dist[nv] = dist[v]+c
                    if c == 0:
                        q.appendleft(nv)
                    else:
                        q.append(nv)

    def is_ok(x):
        edge = [[] for i in range(n)]
        for u, v, c in E:
            if c > x:
                edge[u].append((1, v))
                edge[v].append((1, u))
            else:
                edge[u].append((0, v))
                edge[v].append((0, u))
        d = bfs(0, edge)
        return d < k

    ng = -1
    ok = 2*10**5+50
    while ng+1 < ok:
        mid = (ng+ok)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

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