結果

問題 No.1607 Kth Maximum Card
ユーザー phsplsphspls
提出日時 2022-11-23 19:35:12
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,419 bytes
コンパイル時間 975 ms
コンパイル使用メモリ 178,360 KB
実行使用メモリ 24,200 KB
最終ジャッジ日時 2023-10-25 04:45:08
合計ジャッジ時間 15,828 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1,368 ms
24,200 KB
testcase_09 AC 870 ms
20,220 KB
testcase_10 AC 1,319 ms
24,200 KB
testcase_11 AC 100 ms
7,288 KB
testcase_12 AC 869 ms
19,452 KB
testcase_13 AC 1,186 ms
4,792 KB
testcase_14 AC 677 ms
5,800 KB
testcase_15 TLE -
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 #

use std::collections::VecDeque;


const INF: usize = 1usize << 60;

fn main() {
    let mut nmk = String::new();
    std::io::stdin().read_line(&mut nmk).ok();
    let nmk: Vec<usize> = nmk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nmk[0];
    let m = nmk[1];
    let k = nmk[2];
    let mut paths = vec![vec![]; n];
    for _ in 0..m {
        let mut temp = String::new();
        std::io::stdin().read_line(&mut temp).ok();
        let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let u = temp[0]-1;
        let v = temp[1]-1;
        let c = temp[2];
        paths[u].push((v, c));
        paths[v].push((u, c));
    }

    let mut lower = 0usize;
    let mut upper = INF;
    while upper > lower {
        let middle = (upper + lower) / 2;
        let mut dists = vec![INF; n];
        dists[0] = 0;
        let mut deque = VecDeque::new();
        deque.push_back(0);
        while let Some(u) = deque.pop_front() {
            for &(v, c) in paths[u].iter() {
                let ncost = dists[u] + if c > middle { 1 } else { 0 };
                if ncost >= dists[v] { continue; }
                dists[v] = ncost;
                deque.push_back(v);
            }
        }
        if dists[n-1] < k {
            upper = middle;
        } else {
            lower = middle + 1;
        }
    }
    println!("{}", upper);
}
0