結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-01 07:27:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 383 ms / 2,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 1,001 ms |
| コンパイル使用メモリ | 77,096 KB |
| 最終ジャッジ日時 | 2025-01-12 12:14:02 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#include <iostream>
#include <map>
using lint = long long;
void solve() {
int n, x;
std::cin >> n >> x;
std::map<int, lint> cnt;
while (n--) {
int a;
std::cin >> a;
if (!cnt.count(a)) cnt[a] = 0;
++cnt[a];
}
lint ans = 0;
for (auto [a, c] : cnt) {
if (x == 0) {
ans += c * (c - 1);
} else {
auto b = (a ^ x);
if (cnt.count(b)) ans += c * cnt[b];
}
}
std::cout << ans / 2 << "\n";
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}