結果
| 問題 |
No.862 XORでX
|
| コンテスト | |
| ユーザー |
toku
|
| 提出日時 | 2019-08-09 23:20:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,070 bytes |
| コンパイル時間 | 1,750 ms |
| コンパイル使用メモリ | 161,200 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-19 15:52:06 |
| 合計ジャッジ時間 | 10,365 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 WA * 16 |
ソースコード
#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;
}
}
}
}
toku