結果

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

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri(), x = ri();
	if (n == 1) {
		std::cout << x << std::endl;
		return 0;
	}
	if (x < 4) {
		// //// // / /
		assert(0);
	}
	
	int left = n;
	if (left % 4) left -= left % 4, left += 4;
	
	std::set<int> res;
	for (int i = 1; i < left; i++) {
		if (i / 4 * 4 == x / 4 * 4) {
			left += 4;
			i += 3;
			continue;
		}
		res.insert(i);
	}
	int xorr = 0;
	for (auto i : res) xorr ^= i;
	int sz = res.size();
	for (int i = 0; i < (int) sz + 1 - n; i++) {
		assert(res.count(i + 1));
		res.erase(i + 1);
		xorr ^= i + 1;
	}
	// std::cerr << "xorr:" << xorr << std::endl;
	
	assert(xorr < 4);
	res.insert(x ^ xorr);
	// std::cerr << "size:" << res.size() << std::endl;
	
	assert(res.size() == n);
	for (auto i : res) std::cout << i << std::endl;
	
	return 0;
}
0