結果
| 問題 | No.183 たのしい排他的論理和(EASY) |
| コンテスト | |
| ユーザー |
maromi
|
| 提出日時 | 2024-05-18 18:57:15 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 152 ms / 5,000 ms |
| コード長 | 713 bytes |
| コンパイル時間 | 14,399 ms |
| コンパイル使用メモリ | 392,988 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-20 16:31:26 |
| 合計ジャッジ時間 | 16,970 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
use std::str::FromStr;
use std::{io::*, vec};
fn main() {
let n: usize = read();
let mut a = vec![0; n];
for _i in &mut a {
*_i = read();
}
let mut dp = vec![false; 32768];
dp[0] = true;
for _i in 0..n {
let mut next_dp = dp.clone();
for _j in 0..32768 {
if dp[_j] {
next_dp[_j ^ a[_i]] = true;
}
}
dp = next_dp;
}
println!("{}", dp.iter().filter(|&&x| x).count());
}
pub fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whitespace())
.take_while(|c| !c.is_whitespace())
.collect();
token.parse().ok().expect("failed to parse token")
}
maromi