結果
| 問題 |
No.183 たのしい排他的論理和(EASY)
|
| コンテスト | |
| ユーザー |
sino
|
| 提出日時 | 2021-04-01 14:12:51 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 165 ms / 5,000 ms |
| コード長 | 1,312 bytes |
| コンパイル時間 | 12,949 ms |
| コンパイル使用メモリ | 393,236 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 18:18:49 |
| 合計ジャッジ時間 | 15,160 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#[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);
}
sino