結果

問題 No.1072 A Nice XOR Pair
ユーザー 👑 deuteridayodeuteridayo
提出日時 2020-06-23 00:28:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 611 ms / 2,000 ms
コード長 448 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 176,644 KB
実行使用メモリ 45,452 KB
最終ジャッジ日時 2023-09-16 19:39:21
合計ジャッジ時間 4,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 611 ms
39,284 KB
testcase_08 AC 73 ms
5,048 KB
testcase_09 AC 71 ms
5,088 KB
testcase_10 AC 103 ms
5,008 KB
testcase_11 AC 345 ms
22,236 KB
testcase_12 AC 600 ms
45,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,x;
    cin >> n >> x;
    long ar[n];
    for(int i=0;i<n;i++)cin >> ar[i];
    map<long,long>a;
    map<long,long>b;
    set<long>s;
    for(int i=0;i<n;i++){
        a[ar[i]]++;
        b[ar[i]^x]++;
        s.insert(ar[i]);
    }
    long ans = 0;
    for(long i: s){
        if(x != 0)ans += a[i] * b[i];
        else ans += a[i] * (b[i]-1);
    }
    cout << ans/2 << endl;
}
0