結果
| 問題 | 
                            No.1072 A Nice XOR Pair
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-08 22:32:38 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 816 bytes | 
| コンパイル時間 | 2,156 ms | 
| コンパイル使用メモリ | 172,752 KB | 
| 実行使用メモリ | 12,800 KB | 
| 最終ジャッジ日時 | 2024-12-26 15:04:36 | 
| 合計ジャッジ時間 | 4,200 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 7 WA * 4 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}
int main()
{
    int N, X; cin >> N >> X;
    map<int, int> m;
    rep(i, N) {
        int A; cin >> A;
        m[A]++;
    }
    ll ans = 0;
    for (const auto& p : m) {
        const int& A = p.first;
        const int& c = p.second;
        int B = A^X;
        if (m.count(B) > 0) {
            ans += c * m[B];
        }
    }
    ans /= 2;
    cout << ans << endl;
}