fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define Long long long
  6. #define bint __int128
  7. #define _3bkarm cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false);
  8.  
  9. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  10. #define getrand(l, r) uniform_int_distribution<long long>(l, r)(rng)
  11.  
  12. bool go(int at, int l, int r, int cl, int cr, vector<int> a) {
  13. if (at == a.size()) return false;
  14. if (cl == cr and l == r and cl > 0) return true;
  15. return go(at + 1, l, r, cl, cr, a)
  16. or go(at + 1, (l ^ a[at]), r, cl + 1, cr, a)
  17. or go(at + 1, l, (r ^ a[at]), cl, cr + 1, a);
  18. }
  19.  
  20. bool brute(int n, vector<int> a) {
  21. return go(0, 0, 0, 0, 0, a);
  22. }
  23.  
  24. bool solve(int n, vector<int> a) {
  25. int l = 0, r = 0;
  26. sort( a.begin(), a.end() );
  27. for (int i = 0; i + 1 < n; i += 2) {
  28. l = (l ^ a[i]);
  29. r = (r ^ a[i + 1]);
  30. if (l == r) {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36.  
  37. void get_shit_done() {
  38.  
  39. }
  40.  
  41. signed main() {
  42. _3bkarm
  43.  
  44. int it = 1000;
  45. while (it--) {
  46. int n = 5;
  47. vector<int> a(n);
  48. set<int> st;
  49. for (int i = 0; i < n; ++i) {
  50. while (true) {
  51. a[i] = getrand(1, 10);
  52. if ( st.count(a[i]) == 0 ) {
  53. st.insert(a[i]);
  54. break;
  55. }
  56. }
  57. }
  58.  
  59. // for (int i = 0; i < n; ++i) {
  60. // cin >> a[i];
  61. // }
  62. bool x = solve(n, a);
  63. bool y = brute(n, a);
  64. if (x != y) {
  65. cout << (int)x << ' ' << (int)y << '\n';
  66. for (int t : a) cout << t << ' ';
  67. return 0;
  68. }
  69. }
  70.  
  71. // int ts = 1;
  72. // cin >> ts;
  73. // while (ts--) {
  74. // get_shit_done();
  75. // }
  76.  
  77. return 0;
  78. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1 0
5 7 3 4 2