Advertisement
Jaydeep999997

Odd Topic

Mar 30th, 2021
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int M = 4001;
  5. const int N = 1e5 + 1;
  6.  
  7. bitset<M> a[N], b[N], pa, pb, res;
  8.  
  9. signed main()
  10. {
  11.     ios_base::sync_with_stdio(false);
  12.     cin.tie(NULL); cout.tie(NULL);
  13.  
  14. #ifndef ONLINE_JUDGE
  15.     freopen("input.txt", "r", stdin);
  16.     freopen("output.txt", "w", stdout);
  17. #endif
  18.  
  19.     int n, m, q;
  20.     cin >> n >> m >> q;
  21.     for (int i = 1; i <= n; i++)
  22.     {
  23.         int x;
  24.         cin >> x;
  25.         a[i] = a[i - 1];
  26.         a[i][x] = !a[i][x];
  27.     }
  28.     for (int i = 1; i <= m; i++)
  29.     {
  30.         int x;
  31.         cin >> x;
  32.         b[i] = b[i - 1];
  33.         b[i][x] = !b[i][x];
  34.     }
  35.     for (int i = 1; i <= q; i++)
  36.     {
  37.         int l1, r1, l2, r2;
  38.         cin >> l1 >> r1 >> l2 >> r2;
  39.         pa = (a[r1] ^ a[l1 - 1]);
  40.         pb = (b[r2] ^ b[l2 - 1]);
  41.         res = (pa ^ pb);
  42.         cout << res.count() << '\n';
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement