結果

問題 No.1072 A Nice XOR Pair
ユーザー tonyu0
提出日時 2020-06-05 23:46:42
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 636 bytes
コンパイル時間 11,843 ms
コンパイル使用メモリ 392,144 KB
実行使用メモリ 17,912 KB
最終ジャッジ日時 2024-12-17 19:08:58
合計ジャッジ時間 12,941 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let x: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut map = std::collections::HashMap::new();

    let mut ans = 0;
    for i in 0..n {
        let p = map.entry(x ^ a[i]).or_insert(0);
        ans += *p;
        let q = map.entry(a[i]).or_insert(0);
        *q += 1;
    }
    println!("{}", ans);
}
0