結果
| 問題 | 
                            No.1473 おでぶなおばけさん
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-04-15 03:34:48 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,693 bytes | 
| コンパイル時間 | 12,690 ms | 
| コンパイル使用メモリ | 399,688 KB | 
| 実行使用メモリ | 15,104 KB | 
| 最終ジャッジ日時 | 2024-07-01 02:11:39 | 
| 合計ジャッジ時間 | 48,146 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 38 WA * 9 | 
ソースコード
#![allow(clippy::many_single_char_names)]
use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::io::Read as _;
macro_rules! chmax {
    ($xmax:expr, $x:expr) => {{
        if $xmax < $x {
            $xmax = $x;
            true
        } else {
            false
        }
    }};
}
fn solve(n: usize, graph: &[Vec<(usize, u32)>]) -> (u32, u32) {
    let mut bests = vec![(0, Reverse(u32::MAX)); n];
    let mut que = BinaryHeap::new();
    bests[0] = (u32::MAX, Reverse(0));
    que.push((u32::MAX, Reverse(0), 0));
    while !que.is_empty() {
        let (w, Reverse(k), s) = que.pop().unwrap();
        if (w, Reverse(k)) < bests[s] {
            continue;
        }
        dbg!((s, w, k));
        for &(t, d) in &graph[s] {
            let w_new = w.min(d);
            let k_new = k + 1;
            if chmax!(bests[t], (w_new, Reverse(k_new))) {
                que.push((w_new, Reverse(k_new), t));
            }
        }
    }
    let (ans_w, Reverse(ans_k)) = bests[n - 1];
    (ans_w, ans_k)
}
fn main() {
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut tokens = input.split_ascii_whitespace();
    macro_rules! read {
        ($ty:ty) => {{
            tokens.next().unwrap().parse::<$ty>().unwrap()
        }};
    }
    let n = read!(usize);
    let m = read!(usize);
    let mut graph: Vec<Vec<(usize, u32)>> = vec![vec![]; n];
    for _ in 0..m {
        let s = read!(usize) - 1;
        let t = read!(usize) - 1;
        let d = read!(u32);
        graph[s].push((t, d));
        graph[t].push((s, d));
    }
    let (ans_w, ans_k) = solve(n, &graph);
    println!("{} {}", ans_w, ans_k);
}