fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. const int N = 2e5 + 10;
  5. int arr[N];
  6. int prefixXor[N];
  7. int main() {
  8. int n, q;
  9. cin >> n >> q;
  10. for (int i = 1; i <= n; i++) {
  11. cin >> arr[i];
  12. prefixXor[i] = prefixXor[i - 1] ^ arr[i];
  13. }
  14. while (q--) {
  15. int l, r;
  16. cin >> l >> r;
  17.  
  18. cout << (prefixXor[r] ^ prefixXor[l - 1]) << endl;
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 5284KB
stdin
8 4
3 2 4 5 1 1 5 3
2 4
5 6
1 8
3 3
stdout
3
0
6
4