fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fastio ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  4. #define ll long long
  5. #define int ll
  6. const int mxn = (int)2e5+7;
  7. const int MOD = 998244353;
  8. #define isON(n, k) (((n) >> (k)) & 1)
  9.  
  10. void GETAC(){
  11.  
  12. int n, x, y;
  13. cin >> n >> x >> y;
  14. vector<int> A(n), A1, A2;
  15. for (int& i : A) cin >> i;
  16. int mid(n / 2);
  17. for (int msk(0); msk < (1 << mid); ++msk) {
  18. int xr(0);
  19. for (int i(0); i < mid; ++i)
  20. if (isON(msk, i))
  21. xr ^= A[i];
  22.  
  23. A1.emplace_back(xr);
  24. }
  25.  
  26. for (int msk(0); msk < (1 << (n - mid)); ++msk) {
  27. int xr(0);
  28. for (int i(0); i < n-mid; ++i)
  29. if (isON(msk, i))
  30. xr ^= A[mid + i];
  31.  
  32. A2.emplace_back(xr);
  33. }
  34.  
  35. sort(A1.begin(), A1.end()), sort(A2.begin(), A2.end());
  36. bool ok_x, ok_y;
  37. ok_x = ok_y = 0;
  38. for (int& i : A1) {
  39. if (!ok_x and binary_search(A2.begin(), A2.end(), x ^ i))
  40. ok_x = 1;
  41.  
  42. if (!ok_y and binary_search(A2.begin(), A2.end(), y ^ i))
  43. ok_y = 1;
  44.  
  45. if (ok_x and ok_y)
  46. return void(cout << "YES");
  47.  
  48. }
  49. cout << "NO";
  50. }
  51.  
  52. signed main()
  53. {
  54. fastio
  55. int t(1); cin >> t;
  56. while(t--) GETAC(), cout << '\n';
  57. }
Success #stdin #stdout 0.01s 5516KB
stdin
2
5 1 7
1 2 3 4 5
3 8 9
1 2 3
stdout
YES
NO