結果

問題 No.1072 A Nice XOR Pair
ユーザー Tsukasan_z46
提出日時 2020-06-06 10:17:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 2,654 ms
コンパイル使用メモリ 207,168 KB
最終ジャッジ日時 2025-01-10 23:17:48
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// yukicoder No.1072 A Nice XOR Pair
// 2020.06.06
// mapで管理する

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X; cin >> N >> X;
  map<int, int> A;
  map<int, bool> check;
  set<int> st;
  REP(i, N){
    int a; cin >> a;
    A[a]++;
    check[a] = true;
    st.emplace(a);
  }
  int ans = 0;
  for(auto i : st){
    if(check[i]){
      int tmp = X^i;
      if(A.find(tmp) != A.end()){  // 要素が見つかったら
        ans += A[i]*A[tmp];
        check[i] = false;
        check[tmp] = false;
      }
    }
  }
  cout << ans << endl;
}
0