結果

問題 No.1072 A Nice XOR Pair
ユーザー ninoinui
提出日時 2020-07-19 19:30:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 200,920 KB
最終ジャッジ日時 2025-01-12 00:55:32
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X, A;
  cin >> N >> X;
  map<int, int> MA;
  while (cin >> A) MA[A]++;
  long ans = 0;
  if (X) for (auto [a, b] : MA) ans += (long) b * MA[a ^ X];
  else for (auto [a, b] : MA) ans += (long) b * (b - 1);
  cout << ans / 2 << "\n";
}
0