deadwing97

Untitled

Mar 25th, 2019
478
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // In the Name of Allah
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. typedef long double LD;
  7. typedef long long int LL;
  8. typedef pair <int,int> pii;
  9.  
  10. #define L first
  11. #define R second
  12.  
  13. const int maxn = 1e5 + 100;
  14. int f[maxn], s[maxn];
  15.  
  16. int main() {
  17.     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  18.     int n, q;
  19.     cin >> n >> q;
  20.     for (int i = 1; i <= n; i++)
  21.         cin >> f[i], f[n + 1] ^= f[i];
  22.  
  23.     for (int i = 1; i <= n + 1; i++)
  24.         s[i] = s[i - 1] ^ f[i];
  25.  
  26.     while (q--) {
  27.         int idx;
  28.         cin >> idx;
  29.         idx = ((idx - 1) % (n + 1)) + 1;
  30.         cout << s[idx] << '\n';
  31.     }
  32.  
  33.     return 0;
  34. }
RAW Paste Data