結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー gemmarogemmaro
提出日時 2020-11-04 09:49:13
言語 Rust
(1.72.1)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 789 bytes
コンパイル時間 2,503 ms
コンパイル使用メモリ 142,088 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 15:40:39
合計ジャッジ時間 4,908 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 166 ms
4,380 KB
testcase_08 AC 142 ms
4,384 KB
testcase_09 AC 99 ms
4,380 KB
testcase_10 AC 117 ms
4,380 KB
testcase_11 AC 154 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 130 ms
4,376 KB
testcase_15 AC 160 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 36 ms
4,376 KB
testcase_18 AC 152 ms
4,376 KB
testcase_19 AC 18 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::{convert::TryInto, io::stdin, ops::BitXor};

fn main() {
    let _n = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();
    };

    let a_arry = {
        let mut buf = String::new();
        stdin().read_line(&mut buf).unwrap();

        buf.split_whitespace()
            .map(|s| s.parse::<u16>().unwrap())
            .collect()
    };

    println!("{}", solve(a_arry));
}

fn solve(a_arry: Vec<u16>) -> u16 {
    let mut x_arry = [false; 2 << 14];
    x_arry[0] = true;

    for a in a_arry.iter() {
        for (i, _) in x_arry.clone().iter().enumerate().filter(|(_, &b)| b) {
            let i = (i as u16).bitxor(a);
            x_arry[i as usize] = true;
        }
    }

    x_arry.iter().filter(|&&x| x).count().try_into().unwrap()
}
0