結果
問題 |
No.1072 A Nice XOR Pair
|
ユーザー |
|
提出日時 | 2020-06-24 22:59:39 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 817 bytes |
コンパイル時間 | 12,924 ms |
コンパイル使用メモリ | 394,696 KB |
実行使用メモリ | 8,572 KB |
最終ジャッジ日時 | 2024-07-03 20:24:49 |
合計ジャッジ時間 | 13,784 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 3 |
ソースコード
use std::collections::HashMap; fn main() { let mut nx = String::new(); std::io::stdin().read_line(&mut nx).ok(); let nx: Vec<usize> = nx.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nx[0]; let x = nx[1]; let mut mapping: HashMap<usize, usize> = HashMap::new(); for _ in 0..n { let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: usize = a.trim().parse().unwrap(); if let Some(b) = mapping.get_mut(&a) { *b += 1; } else { mapping.insert(a, 1); } } let mut result: usize = 0; mapping.iter().for_each(|pair| { let b = pair.0 ^ x; result += pair.1 * mapping.get(&b).unwrap_or(&0usize); }); result /= 2; println!("{}", result); }