結果

問題 No.862 XORでX
ユーザー tokutoku
提出日時 2019-08-09 23:20:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,070 bytes
コンパイル時間 1,890 ms
コンパイル使用メモリ 147,044 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 22:05:00
合計ジャッジ時間 15,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;

	if (n % 4 == 1)m -= 2;

	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;
				}
			}
		}
	}
	if (n == 4) {
		FOR(i, m + 1, 100005)FOR(j, i + 1, 100005)FOR(k, j + 1, 100005) {
			int l = x ^ i^j^k;
			if (i == l || j == l || k == l)continue;
			if (k < l&&l <= 100005) {
				cout << i << endl;
				cout << j << endl;
				cout << k << endl;
				cout << l << endl;
				return 0;
			}
		}
	}

	

}
0