結果

問題 No.862 XORでX
ユーザー QCFiumQCFium
提出日時 2019-08-09 23:44:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 786 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 172,960 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2023-09-26 22:11:10
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 19 ms
4,380 KB
testcase_09 AC 19 ms
4,376 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 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 143 ms
6,904 KB
testcase_17 AC 142 ms
6,904 KB
testcase_18 AC 145 ms
7,024 KB
testcase_19 AC 144 ms
7,008 KB
testcase_20 AC 172 ms
8,384 KB
testcase_21 AC 173 ms
8,152 KB
testcase_22 AC 173 ms
8,180 KB
testcase_23 AC 174 ms
8,236 KB
testcase_24 AC 176 ms
8,104 KB
testcase_25 AC 172 ms
8,116 KB
testcase_26 AC 171 ms
8,216 KB
testcase_27 AC 174 ms
8,116 KB
testcase_28 AC 171 ms
8,284 KB
testcase_29 AC 172 ms
8,384 KB
testcase_30 AC 173 ms
8,116 KB
testcase_31 AC 175 ms
8,152 KB
権限があれば一括ダウンロードができます

ソースコード

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);
				}
			}
			for (auto i : all) std::cout << i << std::endl;
			return 0;
		}
	}
	
	return 0;
}
0