fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long q, type, x, a = 0;
  4. void input()
  5. {
  6. cin >> q;
  7. }
  8. void solve()
  9. {
  10. while(q--)
  11. {
  12. cin >> type;
  13.  
  14. if(type == 1)
  15. {
  16. cin >> x;
  17. a ^= x;
  18. }
  19. else if(type == 2)
  20. {
  21. if(a != 0)
  22. {
  23. long long mask =1ll << (63 - __builtin_clzll(a));
  24.  
  25. a ^= mask;
  26. }
  27. }
  28. else
  29. {
  30. cout << __builtin_popcountll(a) << '\n';
  31. }
  32. }
  33. }
  34. int main()
  35. {
  36. ios_base::sync_with_stdio(0);
  37. cin.tie(0);
  38. input();
  39. solve();
  40. }
  41.  
  42.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty