Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define rep(i, a, b) for(int i = a; i < (b); ++i)
- #define trav(a, x) for(auto& a : x)
- #define all(x) begin(x), end(x)
- #define sz(x) (int)(x).size()
- #define subnb true
- #define Lnb true
- typedef long long ll;
- typedef long double ld;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef vector<int> vi;
- const int N = (int)1e5 + 50, B = 60;
- struct Ele {
- ll x;
- int tim;
- };
- int n;
- vector<Ele> upd[N];
- ll a[N];
- map<ll, int> las;
- ll bas[B], sz = 0;
- int pos[B];
- int res[N];
- ll pw[B + 1];
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(NULL);
- pw[0] = 1;
- rep(i, 1, B + 1) pw[i] = pw[i - 1] * 2;
- cin >> n;
- rep(i, 0, n) {
- cin >> a[i];
- if(!las.count(a[i]) || las[a[i]] == -1) {
- las[a[i]] = i;
- } else {
- upd[las[a[i]]].push_back({a[i], i - 1});
- las[a[i]] = -1;
- }
- }
- for (auto &p : las) {
- if(p.second != -1) upd[p.second].push_back({p.first, n - 1});
- }
- for(int i = 0; i < n; i++) {
- for (auto [x, nowpos] : upd[i]) {
- // cout << i << " " << nowpos << ": " << x << endl;
- for(int j = B - 1; j >= 0; j--) {
- if(x & (1LL << j)) {
- if(!bas[j]) {
- bas[j] = x; pos[j] = nowpos;
- break;
- }
- if(pos[j] < nowpos) {
- swap(x, bas[j]);
- swap(nowpos, pos[j]);
- }
- x ^= bas[j];
- }
- }
- }
- rep(j, 0, B) {
- res[i] += bas[j] && pos[j] >= i;
- }
- }
- for(int i = 0; i < n; i++) cout << pw[res[i]] << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement