Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  int k = __builtin_popcount(a ^ b);
  if (k % 2 == 0) {
    cout << "NO" << "\n";
    return 0;
  }
  cout << "YES" << "\n";
  vector<vector<int>> to_one(n + 1);
  to_one[0] = 1;
  to_one[1] = {0, 1};
  for (int i = 2; i <= n; ++i) {
    for (auto x : to_one[i - 1]) {
      to_one[i].push_back(x << 1);
    }
    reverse(to_one[i - 1].begin(), to_one[i - 1].end());
    for (auto x : to_one[i - 1]) {
      to_one[i].push_back(x << 1 | 1);
    }
    reverse(to_one[i - 1].begin(), to_one[i - 1].end());
  }
  vector<vector<int>> to_all(k + 1);
  to_all[1] = {0, 1};
  for (int i = 3; i <= k; i += 2) {
    for (auto x : to_all[i - 2]) {
      to_all[i].push_back(x);
    }
    for (auto x : to_one[i - 2]) {
      to_all[i].push_back(x ^ ((1 << (i - 1)) - 1));
    }
    for (auto x : to_one[i - 1]) {
      to_all[i].push_back(x ^ ((1 << i) - 2));
    }
  }
  vector<int> ans;
  for (auto x : to_all[k]) {
    for (auto y : to_one[n - k]) {
      ans.push_back(y << k | x);
    }
    reverse(to_one[n - k].begin(), to_one[n - k].end());
  }
  vector<int> to_bit(n);
  int ptr = 0;
  for (int i = 0; i < n; ++i) {
    if ((a ^ b) >> i & 1) {
      to_bit[ptr++] = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!((a ^ b) >> i & 1)) {
      to_bit[ptr++] = i;
    }
  }
  for (int i = 0; i < 1 << n; ++i) {
    int real_ans = 0;
    for (int j = 0; j < n; ++j) {
      if (ans[i] >> j & 1) {
        real_ans |= 1 << to_bit[j];
      }
    }
    ans[i] = real_ans;
  }
  for (int i = 0; i < 1 << n; ++i) {
    if (i) {
      cout << " ";
    }
    cout << (ans[i] ^ a);
  }
  cout << "\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:15: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'int')
   21 |   to_one[0] = 1;
      |               ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~