結果

問題 No.183 たのしい排他的論理和(EASY)
コンテスト
ユーザー elphe
提出日時 2026-02-09 16:15:25
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 107 ms / 5,000 ms
+ 56µs
コード長 857 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 793 ms
コンパイル使用メモリ 183,836 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-21 05:39:19
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fn main() {
    let stdin = std::io::read_to_string(std::io::stdin().lock()).unwrap();
    let mut stdin = stdin.split_ascii_whitespace();

    let n: usize = stdin.next().unwrap().parse().unwrap();
    let a: Vec<u16> = (0..n)
        .map(|_| stdin.next().unwrap().parse().unwrap())
        .collect();

    use std::io::Write;
    std::io::stdout()
        .lock()
        .write_all(output(solve(a)).as_bytes())
        .unwrap();
}

fn solve(a: Vec<u16>) -> usize {
    let n = a.len();
    let mut dp = [[false; 1 << 15]; 2];
    dp[0][0] = true;

    a.into_iter().enumerate().for_each(|(i, a)| {
        for j in 0..dp[(i & 1) ^ 1].len() {
            dp[(i & 1) ^ 1][j] = dp[i & 1][j] || dp[i & 1][j ^ a as usize];
        }
    });
    dp[n & 1].into_iter().filter(|&d| d).count()
}

fn output(ans: usize) -> String {
    ans.to_string() + "\n"
}
0