結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー tonyu0
提出日時 2020-04-25 16:16:11
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 618 bytes
コンパイル時間 14,228 ms
コンパイル使用メモリ 379,396 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 06:48:26
合計ジャッジ時間 15,205 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut dp: Vec<bool> = vec![false; 1 << 15];
    dp[0] = true;
    for i in 0..n {
        for j in (0..1 << 15).rev() {
            dp[j ^ a[i]] |= dp[j];
        }
    }

    let mut ans = 0;
    for i in 0..1 << 15 {
        ans += dp[i] as usize;
    }
    println!("{}", ans);
}
0