結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
|
提出日時 | 2020-04-25 21:10:27 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 11,686 ms |
コンパイル使用メモリ | 378,488 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 12:45:43 |
合計ジャッジ時間 | 13,514 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let mut a: Vec<u64> = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); for d in (0..61).rev() { let mut x = 0; let mut j = 0; for i in 0..a.len() { if a[i] >> d == 1 { x = a[i]; j = i; break; } } if x == 0 { continue; } for i in 0..a.len() { a[i] ^= ((a[i] >> d) & 1) * x; } a[j] = x; } let ans = a .iter() .fold(1u64, |acc, x| if *x != 0 { acc << 1 } else { acc }); println!("{}", ans); }