?
№ | Отправитель | Задача | Язык | Вердикт | Время | Память | Отослано | Протест. | |
---|---|---|---|---|---|---|---|---|---|
240087125 |
Дорешивание: Schucking_Sattin |
1100F - 27 | C++14 (GCC 6-32) | Полное решение | 779 мс | 78288 КБ | 2024-01-03 12:29:20 | 2024-01-03 12:29:20 |
// Sea, You & Me #include<bits/stdc++.h> #define LL long long #define DB double #define MOD 1000000007 #define ls(x) (x << 1) #define rs(x) (x << 1 | 1) #define lowbit(x) ((-x) & x) #define MP make_pair #define MT make_tuple #define VI vector<int> #define VL vector<LL> #define VII VI::iterator #define VLI VL::iterator #define all(x) x.begin(), x.end() #define EB emplace_back #define PII pair<int, int> #define SI set<int> #define SII SI::iterator #define fi first #define se second using namespace std; template<typename T> void chkmn(T &a, const T b) { (a > b) && (a = b); } template<typename T> void chkmx(T &a, const T b) { (a < b) && (a = b); } void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); } void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); } void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; } void Sqr(int &a) { a = 1LL * a * a % MOD; } int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; } int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; } int mul(const int &a, const int &b) { return 1LL * a * b % MOD; } int sqr(const int &a) { return 1LL * a * a % MOD; } int qwqmi(int x, int k = MOD - 2) { int res = 1; while(k) { if(k & 1) Mul(res, x); k >>= 1, Sqr(x); } return res; } template<typename T> void read(T &x) { x = 0; int f = 1; char ch = getchar(); while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar(); } while(isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } x = x * f; } const int N = 5e5 + 5; const int V = 20; struct Linear_Base { int b[V], pos[V]; void clear() { for(int i = 0; i < V; ++i) b[i] = pos[i] = 0; } void insert(int x, int p) { for(int i = V - 1; i >= 0; --i) if(x & (1 << i)) { if(!b[i]) return b[i] = x, pos[i] = p, void(); else if(pos[i] < p) swap(pos[i], p), swap(b[i], x); x ^= b[i]; } } int query_max(int l) { int res = 0; for(int i = V - 1; i >= 0; --i) if(b[i] && pos[i] >= l) chkmx(res, res ^ b[i]); return res; } }LB[N]; int n, Q; int main() { read(n); LB[0].clear(); for(int i = 1; i <= n; ++i) { LB[i] = LB[i - 1]; int x; read(x); LB[i].insert(x, i); } read(Q); for(int cas = 1; cas <= Q; ++cas) { int l, r; read(l), read(r); printf("%d\n", LB[r].query_max(l)); } return 0; }
?
?
?
?