結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー sinosino
提出日時 2021-04-01 14:12:51
言語 Rust
(1.77.0)
結果
AC  
実行時間 164 ms / 5,000 ms
コード長 1,312 bytes
コンパイル時間 1,075 ms
コンパイル使用メモリ 150,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 17:50:29
合計ジャッジ時間 3,445 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 145 ms
4,376 KB
testcase_08 AC 146 ms
4,380 KB
testcase_09 AC 100 ms
4,380 KB
testcase_10 AC 120 ms
4,376 KB
testcase_11 AC 158 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 164 ms
4,376 KB
testcase_15 AC 164 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 37 ms
4,376 KB
testcase_18 AC 142 ms
4,380 KB
testcase_19 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

fn main() {
    let _n = read!(usize);
    let a_vec = read!([usize]);

    let mut now  = vec![false; 1 << 15];
    let mut next = vec![false; 1 << 15];

    now[0] = true;
    for e in a_vec {
        // now[i]はeより前の要素のみでiが作れるか否か
        // next[i]がそこにeを加えて作れるものを指すように更新
        for i in 0..now.len() {
            next[i ^ e] = now[i];
        }

        for i in 0..now.len() {
            now[i] |= next[i]
        }
    }
    
    let ans = now
        .into_iter()
        .filter(|&e| e)
        .count();

    println!("{}", ans);
}
0