結果

問題 No.1607 Kth Maximum Card
ユーザー ああいいああいい
提出日時 2022-03-07 11:31:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,297 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 139,908 KB
最終ジャッジ日時 2023-09-29 10:30:38
合計ジャッジ時間 26,303 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,380 KB
testcase_01 AC 85 ms
71,920 KB
testcase_02 WA -
testcase_03 AC 86 ms
71,608 KB
testcase_04 WA -
testcase_05 AC 86 ms
71,736 KB
testcase_06 AC 86 ms
71,392 KB
testcase_07 AC 85 ms
71,384 KB
testcase_08 AC 2,085 ms
136,152 KB
testcase_09 AC 1,706 ms
124,040 KB
testcase_10 AC 2,220 ms
139,908 KB
testcase_11 AC 406 ms
91,864 KB
testcase_12 AC 1,684 ms
124,556 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 226 ms
88,256 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1,086 ms
126,612 KB
testcase_23 AC 1,089 ms
126,776 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1,273 ms
107,080 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 248 ms
98,300 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

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
"""
from collections import deque
def calc(x):
    dist = [-1] * (N+1)
    dist[1] = 0
    q = deque([1])
    while q:
        now = q.popleft()
        for v,c in G[now]:
            if dist[v] >= 0:continue
            if c > x:
                dist[v] = dist[now] + 1
                q.append(v)
            else:
                dist[v] = dist[now]
                q.appendleft(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