結果

問題 No.1072 A Nice XOR Pair
ユーザー merom686merom686
提出日時 2020-06-05 21:37:49
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 639 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 102,932 KB
実行使用メモリ 18,896 KB
最終ジャッジ日時 2023-08-22 14:38:06
合計ジャッジ時間 2,354 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 173 ms
12,940 KB
testcase_08 AC 24 ms
4,376 KB
testcase_09 AC 23 ms
4,380 KB
testcase_10 AC 35 ms
4,376 KB
testcase_11 AC 100 ms
9,088 KB
testcase_12 AC 195 ms
18,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, x;
    cin >> n >> x;

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        mp[a]++;
    }

    ll r = 0;
    for (const auto& [a, k] : mp) {
        int b = a ^ x;
        if (a == b) {
            r += (ll)k * (k - 1);
        } else {
            r += (ll)k * mp[b];
        }
    }

    cout << r / 2 << endl;

    return 0;
}
0