結果

問題 No.1072 A Nice XOR Pair
ユーザー Tsukasan_z46Tsukasan_z46
提出日時 2020-06-06 10:17:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 2,946 ms
コンパイル使用メモリ 214,288 KB
実行使用メモリ 31,436 KB
最終ジャッジ日時 2023-08-24 21:23:43
合計ジャッジ時間 5,448 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 4 ms
4,384 KB
testcase_07 AC 461 ms
31,436 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 257 ms
15,608 KB
testcase_12 AC 427 ms
28,812 KB
権限があれば一括ダウンロードができます

ソースコード

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