結果

問題 No.1072 A Nice XOR Pair
ユーザー yuji9511yuji9511
提出日時 2020-06-05 21:44:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 1,448 ms
コンパイル使用メモリ 170,840 KB
実行使用メモリ 25,620 KB
最終ジャッジ日時 2023-08-22 14:50:24
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 189 ms
17,404 KB
testcase_08 AC 29 ms
4,940 KB
testcase_09 AC 27 ms
4,928 KB
testcase_10 AC 50 ms
4,952 KB
testcase_11 AC 137 ms
12,484 KB
testcase_12 AC 226 ms
25,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N,X;
    cin >> N >> X;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    map<ll,ll> mp;
    rep(i,0,N) mp[A[i]]++;
    ll ans = 0;
    rep(i,0,N){
        ll v = (A[i]^X);
        if(v == A[i]){
            ans += mp[A[i]]-1;
        }else{
            ans += mp[v];
        }
    }
    ans /= 2;
    print(ans);
    

}

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