提出 #66735721


ソースコード 拡げる

#[allow(unused_imports)]
use ac_library::*;
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::{marker::*, *};
#[allow(unused_imports)]
use rand::Rng;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    input! {
        n: usize,
        m: usize,
    }
    let mut es = (0..n).map(|_| vec![]).collect::<Box<_>>();
    for _ in 0..m {
        input! {
            a: Usize1,
            b: Usize1,
            w: u16,
        }
        es[a].push((b, w));
    }
    let mut dp = (0..n).map(|_| vec![false; 1024]).collect::<Vec<_>>();
    dp[0][0] = true;
    let mut st = vec![(0, 0)];
    while let Some((v, w)) = st.pop() {
        for &(u, y) in &es[v] {
            let w = w ^ y;
            if dp[u][w as usize] {
                continue;
            }
            dp[u][w as usize] = true;
            st.push((u, w));
        }
    }
    if let Some(ans) = dp[n - 1]
        .iter()
        .enumerate()
        .filter_map(|(i, &v)| v.then_some(i))
        .next()
    {
        println!("{ans}");
    } else {
        println!("-1");
    }
}

提出情報

提出日時
問題 D - XOR Shortest Walk
ユーザ Yukkku
言語 Rust (rustc 1.70.0)
得点 400
コード長 1201 Byte
結果 AC
実行時間 9 ms
メモリ 3360 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 33
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 1 ms 1948 KiB
hand_02.txt AC 1 ms 1816 KiB
hand_03.txt AC 1 ms 1924 KiB
hand_04.txt AC 1 ms 1868 KiB
hand_05.txt AC 1 ms 1880 KiB
hand_06.txt AC 1 ms 2016 KiB
hand_07.txt AC 1 ms 2076 KiB
hand_08.txt AC 1 ms 2000 KiB
random_01.txt AC 1 ms 1944 KiB
random_02.txt AC 1 ms 2424 KiB
random_03.txt AC 1 ms 1804 KiB
random_04.txt AC 1 ms 2340 KiB
random_05.txt AC 1 ms 1832 KiB
random_06.txt AC 1 ms 2004 KiB
random_07.txt AC 1 ms 1920 KiB
random_08.txt AC 1 ms 2340 KiB
random_09.txt AC 1 ms 1964 KiB
random_10.txt AC 1 ms 2916 KiB
random_11.txt AC 1 ms 2084 KiB
random_12.txt AC 1 ms 2324 KiB
random_13.txt AC 2 ms 2236 KiB
random_14.txt AC 5 ms 2744 KiB
random_15.txt AC 1 ms 2120 KiB
random_16.txt AC 1 ms 2224 KiB
random_17.txt AC 1 ms 2868 KiB
random_18.txt AC 1 ms 2884 KiB
random_19.txt AC 9 ms 2952 KiB
random_20.txt AC 4 ms 2844 KiB
random_21.txt AC 5 ms 3360 KiB
random_22.txt AC 5 ms 3296 KiB
sample_01.txt AC 1 ms 1808 KiB
sample_02.txt AC 1 ms 2072 KiB
sample_03.txt AC 1 ms 2868 KiB