lina_os

Untitled

Jul 2nd, 2025
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define ul unsigned long long
  5. #define ld long double
  6. #define vll(v) vector<ll>v
  7. //#define vll(v,n) vector<ll>v(n);
  8. #define mll(m) map<ll,ll>m;
  9. #define sll(s) set<ll>s;
  10. #define iv(v) for(auto &i:v) cin >> i;
  11. #define ov(v) for(auto &i:v) cout << i << " ";
  12. #define all(v) (v.begin(),v.end());
  13. #define Bismillah ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  14.  
  15. using namespace std;
  16.  
  17. string toBin(ll n) {
  18.     string s;
  19.     while (n) {
  20.         s.push_back(n%2+'0');
  21.         n/=2;
  22.     }
  23.     reverse(s.begin(), s.end());
  24.     return s;
  25. }
  26.  
  27. ll toDec(string s) {
  28.     reverse(s.begin(), s.end());
  29.     ll n=0;
  30.     for (int i=0; i<s.size(); i++) {
  31.         n+=(s[i]-'0') * (1<<i);
  32.     }
  33.     return n;
  34. }
  35.  
  36. void solve() {
  37.     ll n,x;
  38.     cin >> n >> x;
  39.     if (n==2 && x==0) {
  40.         cout << "NO"; return;
  41.     }
  42.     cout << "YES" << endl;
  43.     if (n==1) cout << x;
  44.     else if (n==2) cout << 1 << " " << (x^1);
  45.     else {
  46.         ll xr=x;
  47.         for (ll i=1; i<n; i++) {
  48.             xr^=i;
  49.         }
  50.         for (ll i=n-1; i>0; i--) {
  51.             if (i!=xr) {
  52.                 for (int j=1; j<n; j++) {
  53.                     if (j==i) j+=(1<<18);
  54.                     cout << j << ' ';
  55.                 }
  56.                 cout << xr+(1<<18);
  57.                 break;
  58.             }
  59.         }
  60.     }
  61. }
  62.  
  63. int main() {
  64.     Bismillah
  65.     ll t=1;
  66. //    cin >> t;
  67.     while (t--) {
  68.         solve();
  69.     }
  70.     return 0;
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment