結果
| 問題 | No.183 たのしい排他的論理和(EASY) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-09 16:06:01 |
| 言語 | Rust (1.93.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 5,000 ms |
| コード長 | 955 bytes |
| 記録 | |
| コンパイル時間 | 1,468 ms |
| コンパイル使用メモリ | 202,804 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-02-09 16:06:06 |
| 合計ジャッジ時間 | 3,862 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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>) -> u16 {
let mut ans = 1;
let mut is_reachable = [false; 1 << 15];
let mut stk = Vec::new();
is_reachable[0] = true;
stk.push(0);
while let Some(cur) = stk.pop() {
a.iter().for_each(|&a| {
if !is_reachable[(cur ^ a) as usize] {
is_reachable[(cur ^ a) as usize] = true;
ans += 1;
stk.push(cur ^ a);
}
});
}
ans
}
fn output(ans: u16) -> String {
ans.to_string() + "\n"
}