結果
問題 |
No.1072 A Nice XOR Pair
|
ユーザー |
|
提出日時 | 2022-01-23 12:27:31 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,082 bytes |
コンパイル時間 | 15,162 ms |
コンパイル使用メモリ | 377,192 KB |
実行使用メモリ | 12,068 KB |
最終ジャッジ日時 | 2024-11-29 11:00:06 |
合計ジャッジ時間 | 15,805 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 4 |
ソースコード
#[macro_export] macro_rules! setup { { mut $input:ident: SplitWhitespace $(,)? } => { use std::io::Read; let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).ok(); let mut $input = buf.split_whitespace(); }; } #[macro_export] macro_rules! parse_next { ($str_iter:expr) => { $str_iter.next().unwrap().parse().ok().unwrap() }; } fn main() { setup! { mut input: SplitWhitespace }; let n: usize = parse_next!(input); let x: usize = parse_next!(input); let a: Vec<usize> = (0..n).map(|_| parse_next!(input)).collect(); let mut map = std::collections::HashMap::new(); for i in 0..n { let key = x ^ a[i]; if let Some(value) = map.get_mut(&key) { *value += 1; } else { map.insert(key, 1); } } let ans = (|| { let mut count = 0; for i in 0..n { if let Some(value) = map.get(&a[i]) { count += *value; } } count / 2 })(); println!("{}", ans); }