結果

問題 No.1072 A Nice XOR Pair
ユーザー chocoruskchocorusk
提出日時 2020-06-05 21:24:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 1,113 ms
コンパイル使用メモリ 129,784 KB
実行使用メモリ 5,028 KB
最終ジャッジ日時 2023-08-22 14:07:35
合計ジャッジ時間 2,579 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 116 ms
4,968 KB
testcase_08 AC 90 ms
4,952 KB
testcase_09 AC 88 ms
4,972 KB
testcase_10 AC 96 ms
4,904 KB
testcase_11 AC 87 ms
4,956 KB
testcase_12 AC 97 ms
5,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;ll x; cin>>n>>x;
    ll a[200020];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a, a+n);
    ll ans=0;
    for(int i=0; i<n; i++){
        ll b=(x^a[i]);
        ans+=(upper_bound(a, a+n, b)-lower_bound(a, a+n, b));
        if(x==0) ans--;
    }
    cout<<ans/2<<endl;
    return 0;
}
0