結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2020-06-05 21:53:38 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 974 ms / 2,000 ms |
| コード長 | 658 bytes |
| コンパイル時間 | 2,248 ms |
| コンパイル使用メモリ | 76,012 KB |
| 実行使用メモリ | 77,224 KB |
| 最終ジャッジ日時 | 2024-12-17 14:26:09 |
| 合計ジャッジ時間 | 9,745 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
sc.close();
long ans = 0;
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < n; i++) {
int b = x ^ a[i];
if (map.containsKey(b)) {
ans += map.get(b);
}
if (map.containsKey(a[i])) {
map.put(a[i], map.get(a[i]) + 1);
} else {
map.put(a[i], 1);
}
}
System.out.println(ans);
}
}
ks2m