結果

問題 No.1072 A Nice XOR Pair
ユーザー ngtkanangtkana
提出日時 2020-06-05 21:43:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,198 bytes
コンパイル時間 2,757 ms
コンパイル使用メモリ 204,928 KB
実行使用メモリ 4,760 KB
最終ジャッジ日時 2023-08-22 14:49:01
合計ジャッジ時間 3,225 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 54 ms
4,664 KB
testcase_08 AC 34 ms
4,520 KB
testcase_09 AC 33 ms
4,564 KB
testcase_10 AC 39 ms
4,524 KB
testcase_11 AC 46 ms
4,552 KB
testcase_12 AC 49 ms
4,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    u64 X;
    std::cin >> n >> X;
    vec<u64> a(n);
    for (u64& x:a) std::cin >> x;
    std::sort(ALL(a));

    u64 ans = 0;
    for (usize x: a) {
        auto [lb, ub] = std::equal_range(ALL(a), X ^ x);
        ans += ub - lb;
    }
    if (X == 0) ans -= n;
    assert(ans % 2 == 0);
    std::cout << ans / 2 << '\n';
}
0