# Codeforces 862 C. Mahmoud and Ehab and the xor （技巧）

## Description

Mahmoud and Ehab are on the third stage of their adventures now. As you know, Dr. Evil likes sets. This time he won’t show them any set from his large collection, but will ask them to create a new set to replenish his beautiful collection of sets.

Dr. Evil has his favorite evil integer x. He asks Mahmoud and Ehab to find a set of n distinct non-negative integers such the bitwise-xor sum of the integers in it is exactly x. Dr. Evil doesn’t like big numbers, so any number in the set shouldn’t be greater than 10^6.

## Input

The only line contains two integers n and x (1 ≤ n ≤ 10^5, 0 ≤ x ≤ 10^5) — the number of elements in the set and the desired bitwise-xor, respectively.

## Output

If there is no such set, print “NO” (without quotes).

Otherwise, on the first line print “YES” (without quotes) and on the second line print n distinct integers, denoting the elements in the set is any order. If there are multiple solutions you can print any of them.

## Examples input

5 5


## Examples output

YES
1 2 4 5 7


## AC 代码

#include <bits/stdc++.h>
using namespace std;
#define IO                       \
ios::sync_with_stdio(false); \
cin.tie(0);
typedef __int64 LL;
const int maxn = 1e5 + 10;
const int pr = 1 << 17;
int n, k;

void solve()
{
if (n < 3)
{
if (n == 1)
{
cout << k << endl;
}
else
{
cout << 0 << " " << k << endl;
}
return;
}
vector<int> ans;
LL cnt = 0;
for (int i = 1; i <= n - 3; i++)
{
cnt ^= i;
ans.push_back(i);
}
if (cnt == k)
{
ans.push_back(pr);
ans.push_back(pr << 1);
ans.push_back(pr ^ (pr << 1));
}
else
{
ans.push_back(0);
ans.push_back(pr);
ans.push_back(pr ^ k ^ cnt);
}
sort(ans.begin(), ans.end());
int len = ans.size();
for (int i = 0; i < len; i++)
{
cout << ans[i] << (i != len - 1 ? " " : "\n");
}
}

int main()
{
IO;
cin >> n >> k;
if (n == 2 && k == 0)
cout << "NO" << endl;
else
{
cout << "YES" << endl;
solve();
}
return 0;
}