結果

問題 No.1607 Kth Maximum Card
ユーザー ああいいああいい
提出日時 2022-03-07 11:25:52
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 885 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 148,044 KB
最終ジャッジ日時 2023-09-29 10:23:09
合計ジャッジ時間 41,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,312 KB
testcase_01 AC 79 ms
71,276 KB
testcase_02 AC 79 ms
71,364 KB
testcase_03 AC 76 ms
71,308 KB
testcase_04 AC 74 ms
71,304 KB
testcase_05 AC 76 ms
71,476 KB
testcase_06 AC 79 ms
71,096 KB
testcase_07 AC 78 ms
71,268 KB
testcase_08 AC 2,695 ms
140,744 KB
testcase_09 AC 1,843 ms
133,288 KB
testcase_10 TLE -
testcase_11 AC 484 ms
93,080 KB
testcase_12 AC 2,395 ms
129,168 KB
testcase_13 AC 665 ms
88,736 KB
testcase_14 AC 630 ms
90,112 KB
testcase_15 AC 2,153 ms
123,472 KB
testcase_16 AC 491 ms
87,264 KB
testcase_17 AC 420 ms
82,472 KB
testcase_18 AC 1,383 ms
107,788 KB
testcase_19 AC 1,033 ms
98,524 KB
testcase_20 AC 1,452 ms
103,008 KB
testcase_21 AC 1,488 ms
104,588 KB
testcase_22 AC 1,285 ms
130,896 KB
testcase_23 AC 1,508 ms
134,140 KB
testcase_24 AC 1,123 ms
98,744 KB
testcase_25 AC 735 ms
91,292 KB
testcase_26 AC 868 ms
93,692 KB
testcase_27 AC 1,238 ms
100,172 KB
testcase_28 AC 1,052 ms
96,712 KB
testcase_29 AC 1,957 ms
113,200 KB
testcase_30 AC 3,346 ms
137,976 KB
testcase_31 AC 2,094 ms
112,400 KB
testcase_32 AC 350 ms
98,888 KB
testcase_33 AC 336 ms
99,068 KB
testcase_34 AC 366 ms
98,832 KB
testcase_35 AC 354 ms
98,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
rr = sys.stdin

N,M,K = map(int,rr.readline().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    a,b,c = map(int,rr.readline().split())
    G[a].append((b,c))
    G[b].append((a,c))

import heapq
inf = 10 ** 6
base = 23
mask = (1 << base) - 1
def calc(x):
    dist = [K] * (N+1)
    dist[1] = 0
    q = [1]
    while q:
        u = heapq.heappop(q)
        d,now = u >> base,u & mask
        if now == N:break
        if dist[now] < d:
            continue
        for v,c in G[now]:
            if c > x:
                c = 1
            else:
                c = 0
            if dist[v] > d + c:
                dist[v] = d + c
                heapq.heappush(q,(d+c) << base | v)
    return dist[N] < K
start = -1
end = 2 * 10 ** 5
while end - start > 1:
    mid = (end + start) // 2
    if calc(mid):
        end = mid
    else:
       start = mid
print(end)
0