結果
| 問題 | No.183 たのしい排他的論理和(EASY) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-09 16:15:25 |
| 言語 | Rust (1.93.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 189 ms / 5,000 ms |
| コード長 | 857 bytes |
| 記録 | |
| コンパイル時間 | 1,623 ms |
| コンパイル使用メモリ | 201,648 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-02-09 16:15:30 |
| 合計ジャッジ時間 | 4,677 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
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"
}