結果

問題 No.1072 A Nice XOR Pair
ユーザー ldsybldsyb
提出日時 2020-06-05 21:50:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 1,738 ms
コンパイル使用メモリ 171,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 20:50:14
合計ジャッジ時間 3,021 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 88 ms
5,376 KB
testcase_08 AC 80 ms
5,376 KB
testcase_09 AC 80 ms
5,376 KB
testcase_10 AC 89 ms
5,376 KB
testcase_11 AC 73 ms
5,376 KB
testcase_12 AC 80 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t n, x;
	cin >> n >> x;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	sort(as.begin(), as.end());

	int64_t ans = 0;
	for (int64_t i = 0; i < n; i++)
	{
		ans += distance(lower_bound(as.begin() + i + 1, as.end(), as[i] ^ x), upper_bound(as.begin() + i + 1, as.end(), as[i] ^ x));
	}

	cout << ans << endl;

	return 0;
}
0