結果

問題 No.862 XORでX
ユーザー QCFiumQCFium
提出日時 2019-08-09 23:42:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 814 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 173,320 KB
実行使用メモリ 8,264 KB
最終ジャッジ日時 2023-09-26 22:10:54
合計ジャッジ時間 8,439 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 19 ms
4,380 KB
testcase_10 AC 22 ms
4,380 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
uint32_t xorshift() {
	static uint32_t x = 2463534242;
	x ^= x << 13;
	x ^= x >> 17;
	x ^= x << 15;
	return x;
}
int main() {
	int n = ri(), x = ri();
	bool inv = false;
	if (n >= 50000) n = 100005 - n, inv = true, x ^= 1;
	
	while (1) {
		std::set<int> all;
		int xorr = x;
		for (int i = 0; i + 1 < n; i++) {
			int cur;
			do cur = xorshift() % 100005 + 1; while (all.count(cur));
			all.insert(cur);
			xorr ^= cur;
		}
		if (xorr && xorr <= 100005 && !all.count(xorr)) {
			all.insert(xorr);
			if (inv) {
				for (int i = 1; i <= 100005; i++) {
					if (all.count(i)) all.erase(i);
					else all.insert(i);
				}
			}
			assert(all.size() == n);
			for (auto i : all) std::cout << i << std::endl;
			return 0;
		}
	}
	
	return 0;
}
0