Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- const int N = 1e6 + 10;
- void solve() {
- int n,l,r;
- cin >> n >> l >> r;
- // re
- vector<int> v(n + 1);
- for (int i = 1; i <= n; i++) {
- cin >> v[i];
- }
- map<int, int> dp;
- dp[0] = 0;
- dp[1] = dp[2] = dp[3] = v[1];
- for (int i = 4; i <= n; i++) {
- dp[i] = dp[i - 2] ^ v[i / 2];
- }
- // cout << "as";
- // return ;
- function<int(int)> fun = [&](int x) {
- if(x <= 0){
- return 0ll;
- }
- if (dp.count(x)){
- return dp[x];
- }
- return dp[x] = fun(x - 2) ^ fun(x / 2);
- };
- cout << fun(l);
- }
- int32_t main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin >> t;
- while (t--) {
- solve();
- cout << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment