結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-09 19:18:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 348 ms / 2,000 ms |
| コード長 | 599 bytes |
| コンパイル時間 | 1,593 ms |
| コンパイル使用メモリ | 180,456 KB |
| 実行使用メモリ | 25,344 KB |
| 最終ジャッジ日時 | 2024-11-28 16:34:52 |
| 合計ジャッジ時間 | 3,801 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
int main() {
int n, x;
cin >> n >> x;
set<int> s;
map<int, ll> mp;
rep(i,n) {
int a;
cin >> a;
s.insert(a);
mp[a]++;
}
ll ans = 0;
if (x == 0) {
for (auto it : mp) {
ans += it.second * (it.second-1)/2;
}
cout << ans << endl;
return 0;
}
for (int ax : s) {
auto it = s.find(ax^x);
if (it != s.end()) {
ans += mp[ax]*mp[ax^x];
}
}
ans /= 2;
cout << ans << endl;
}