Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. #define int long long
  4.  
  5. signed main() {
  6.     ios_base::sync_with_stdio(0);
  7.     cin.tie(0);
  8.     cout.tie(0);
  9.     int n, q;
  10.     cin >> n >> q;
  11.     int xornow = 0, am = 0;
  12.     for (int i = 0; i < n; i++) {
  13.         int a;
  14.         cin >> a;
  15.         xornow ^= a;
  16.         am++;
  17.     }
  18.     while (q--) {
  19.         int t;
  20.         cin >> t;
  21.         if (t == 3) {
  22.             if (xornow == 0) {
  23.                 cout << am << "\n";
  24.             }
  25.             else {
  26.                 cout << 0 << "\n";
  27.             }
  28.         }
  29.         else if (t == 2) {
  30.             int x;
  31.             cin >> x;
  32.             xornow ^= x;
  33.             am++;
  34.         }
  35.         else {
  36.             int x;
  37.             cin >> x;
  38.             am--;
  39.             xornow ^= x;
  40.         }
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement