結果

問題 No.862 XORでX
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2018-08-14 19:39:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 1,414 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 95,552 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:12:29
合計ジャッジ時間 4,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<end

int main(void) {
	int n,x;
	cin>>n>>x;
	int n1 = n % 4;
	if(n1==0)n1+=4;
	n -= n1;
	vector<int> v;
	v.pb(1);
	if(x==1){
		v.pb(2);
		v.pb(3);
		v.pb(4);
		v.pb(7);
	}
	vector<int> v1;
	for(int i = 2; i < 100006; i+=4){
		if(i<=x&&x<i+4){
			for(int j = i; j < i+4; j++){
				v.pb(j);
			}			
		}
		else{
			if(x==1&&i<10)continue;
			for(int j = i; j < i+4; j++){
				if(n>0)v1.pb(j);
				n--;
			}
		}
	}
	do{
		int a = 0;
		for(int i = 0; i < n1; i++){
			a ^= v[i];
		}
		if(a==x){
			for(int i = 0; i < n1; i++){
				v1.pb(v[i]);
			}			
			break;
		}
	}while(next_permutation(all(v)));
	for(int i = 0; i < v1.sz; i++){
		cout << v1[i] << endl;
	}
	return 0;
}
0