結果

問題 No.862 XORでX
ユーザー tokutoku
提出日時 2019-08-09 23:10:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,766 bytes
コンパイル時間 1,934 ms
コンパイル使用メモリ 146,108 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 21:52:01
合計ジャッジ時間 12,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 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 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 15 ms
4,376 KB
testcase_09 AC 15 ms
4,376 KB
testcase_10 AC 15 ms
4,380 KB
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 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 AC 128 ms
4,376 KB
testcase_25 RE -
testcase_26 WA -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



int main() {

	int n, x;
	cin >> n >> x;

	VI v(20, 0);
	int sum = 0;
	REP(i, 20) {
		if ((1 << i)&x) {
			v[i]++;
			sum++;
		}
	}

	if (n == 1) {
		cout << x << endl;
		return 0;
	}
	if (n == 2) {
		if (x == 1) {
			cout << 2 << endl;
			x ^= 2;
			cout << x << endl;
		}
		else {
			cout << 1 << endl;
			x ^= 1;
			cout << x << endl;
		}
		return 0;
	}
	int m = n;
	if (m % 2 == 0)m--;
	m -= 2;
	int a = 0;

	FOR(i, 1, m + 1) {
		cout << i << endl;
		a ^= i;
		n--;
	}

	x ^= a;

	if (n == 2) {
		FOR(i, m + 1, 100005) {
			int j = x ^ i;
			if (m < j&&j <= 100005) {
				cout << j << endl;
				cout << i << endl;
				return 0;
			}
		}
	}
	if (n == 3) {
		FOR(i, m + 1, 100005) {
			FOR(j, m + 1, 100005) {
				if (i == j)continue;
				int k = x ^ i;
				k ^= j;
				if (k == i || k == j)continue;
				if (m < k&&k <= 100005) {
					cout << i << endl;
					cout << j << endl;
					cout << k << endl;
					return 0;
				}
			}
		}
	}
	
	assert(n == 0);

	

}
0