結果

問題 No.1072 A Nice XOR Pair
ユーザー legosukelegosuke
提出日時 2020-06-16 04:09:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 652 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 209,848 KB
実行使用メモリ 25,280 KB
最終ジャッジ日時 2023-09-16 10:50:06
合計ジャッジ時間 3,961 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 274 ms
17,020 KB
testcase_08 AC 29 ms
4,632 KB
testcase_09 AC 27 ms
4,556 KB
testcase_10 AC 51 ms
4,576 KB
testcase_11 AC 193 ms
12,308 KB
testcase_12 AC 342 ms
25,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        mp[A[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (X) ans += mp[A[i] ^ X];
        else ans += mp[A[i]] - 1;
    }
    ans >>= 1;
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
0