結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-06-05 21:43:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 1,198 bytes |
| コンパイル時間 | 2,017 ms |
| コンパイル使用メモリ | 200,208 KB |
| 最終ジャッジ日時 | 2025-01-10 22:24:50 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#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';
}
ngtkana