Untitled
unknown
plain_text
a year ago
1.2 kB
18
Indexable
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n; cin >> n;
vector<int> v(n + 1);
set<pair<int , int>> pr , pairs;
for(int i = 1; i <= n; ++i) {
cin >> v[i];
v[i] ^= v[i - 1];
pr.insert({v[i] , i});
}
pr.insert({0 , 0});
for(int i = 0; i < n; ++i) {
auto it = pr.lower_bound({v[i] , 0});
pr.erase(it);
it = pr.lower_bound({v[i] , 0});
if(it != pr.end() && it->first == v[i]) {
pairs.insert({it->second , i + 1});
}
}
int q , l , r;
cin >> q;
while (q --) {
cin >> l >> r;
auto it = pairs.lower_bound({r , l});
if(it != pairs.end() && it->first == r && it->second >= l) cout << "YES\n";
else {
if(!pairs.empty() && it != pairs.begin()) it --;
cout << ((it != pairs.end() && it->first <= r && it->second >= l) ? "YES\n" : "NO\n");
}
}
}
int32_t main() {
std::ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cout.tie(nullptr);
cin.tie(nullptr);
int t = 1; //cin >> t;
while (t--)solve();
}Editor is loading...
Leave a Comment