Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define for0(i, n) for(int i = 0; i < n; i++)
  3. #define for1(i, n) for(int i = 1; i <= n; i++)
  4. #define pb push_back
  5. #define mp make_pair
  6. #define all(v) v.begin(), v.end()
  7. #define V vector<int>
  8. #define VP vector<pair<int, int> >
  9. #define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  10. using namespace std;
  11. #ifdef _WIN32
  12. #include <windows.h>
  13. #define print(x) PRINT(x, #x)
  14. template<typename T> inline const void PRINT(T VARIABLE, string NAME)
  15. {
  16. #ifndef ONLINE_JUDGE /// ONLINE_JUDGE IS DEFINED ON CODEFORCES
  17.     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  18.     SetConsoleTextAttribute(hConsole, 10);
  19.     cerr << NAME << " = " << VARIABLE;
  20.     SetConsoleTextAttribute(hConsole, 7);
  21.     cerr << '\n';
  22. #endif
  23. }
  24. #else
  25. #define print(x) 0
  26. #endif
  27. struct pair_hash
  28. {
  29.     template<typename T1, typename T2>
  30.     size_t operator () (const pair<T1, T2> &p) const
  31.     {
  32.         auto h1 = hash<T1> {}(p.first);
  33.         auto h2 = hash<T2> {}(p.second);
  34.         return h1 ^ h2;
  35.     }
  36. };
  37. typedef long long ll;
  38. typedef unsigned long long ull;
  39. const ll INFLL = 2 * (ll)1e18 + 100;
  40. const int INFINT = 2 * (int)1e9 + 100;
  41. //ifstream fin(".in");
  42. //ofstream fout(".out");
  43. void die()
  44. {
  45.     cout << "-1\n";
  46.     exit(0);
  47. }
  48. const int NMAX = 1e5 + 5;
  49. const int MOD = 1e9 + 7; /// careful here (7 or 9, 66.. etc)
  50. const double PI = atan(1) * 4;
  51. const double EPS = 1e-12;
  52.  
  53. V r, sol;
  54. int n, x;
  55.  
  56. int main()
  57. {
  58.     FASTIO;
  59.     cin >> n >> x;
  60.     for0(i, (int)1e5 + 1) if(i != x) r.pb(i);
  61.  
  62.     for1(aux, 500)
  63.     {
  64.         random_shuffle(all(r));
  65.         vector<bool> in(NMAX, 0);
  66.         int cur = 0;
  67.         for0(i, n - 1) cur ^= r[i], in[r[i]] = 1;
  68.         if(cur == 0)
  69.         {
  70.             cout << "YES\n";
  71.             for0(i, n - 1) cout << r[i] << ' ';
  72.             cout << x;
  73.             print(aux);
  74.             return 0;
  75.         }
  76.         if(!in[cur ^ x])
  77.         {
  78.             cout << "YES\n";
  79.             for0(i, n - 1) cout << r[i] << ' ';
  80.             cout << (cur ^ x);
  81.             print(aux);
  82.             return 0;
  83.         }
  84.     }
  85.  
  86.     cout << "NO";
  87.  
  88.  
  89.  
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement