結果
問題 |
No.1072 A Nice XOR Pair
|
ユーザー |
|
提出日時 | 2020-06-24 23:06:09 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 948 bytes |
コンパイル時間 | 13,056 ms |
コンパイル使用メモリ | 397,452 KB |
実行使用メモリ | 8,460 KB |
最終ジャッジ日時 | 2024-07-03 20:25:35 |
合計ジャッジ時間 | 13,536 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 4 |
ソースコード
use std::collections::HashMap; //TODO 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; if x != 2 { result += pair.1 * mapping.get(&b).unwrap_or(&0usize); } else { result += pair.1 * (pair.1 - 1) / 2; } }); if x != 0 { result /= 2; } println!("{}", result); }