結果

問題 No.1072 A Nice XOR Pair
ユーザー QDSNQDSN
提出日時 2020-06-06 22:16:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 355 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 175,720 KB
実行使用メモリ 25,180 KB
最終ジャッジ日時 2023-08-25 02:05:29
合計ジャッジ時間 3,781 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 318 ms
17,104 KB
testcase_08 AC 80 ms
4,700 KB
testcase_09 AC 78 ms
4,592 KB
testcase_10 AC 99 ms
4,872 KB
testcase_11 AC 207 ms
12,384 KB
testcase_12 AC 355 ms
25,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 998244353
using namespace std;
int main() {
    ll n, x;
    cin >> n >> x;
    map<ll, ll> mp;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] == (a[i] ^ x)) {
            ans--;
        }
        ans += mp[a[i] ^ x];
    }
    cout << ans / 2 << endl;
}
0