题解:CF2066C Bitwise Slides

· · 题解

CF2066C Object Identification

题意:

解法:

代码:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <ctime>
#include <random>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <ext/pb_ds/assoc_container.hpp>
#define pii pair<int, int>
#define fi first
#define se second
#define MP make_pair
#define ep emplace
#define eb emplace_back
#define int long long
#define rep(i, j, k) for (int i = (j); i <= (k); i++)
#define per(i, j, k) for (int i = (j); i >= (k); i--)
typedef double db;
typedef long double ldb;
typedef long long ll;
//typedef __int128 lll;
typedef unsigned long long ull;
typedef unsigned int ui;
using namespace std;
using namespace __gnu_pbds;
bool Mbe;

//char buf[1<<20],*p1,*p2;
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin), p1 == p2) ? 0 : *p1++)
int read() {
    int s = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f ^= (c == '-'), c = getchar();
    while (c >= '0' && c <= '9') s = s * 10 + c - '0', c = getchar();
    return f ? s : -s;
}
template<typename T>void chkmax(T&x,const T&y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,const T&y){if(x>y)x=y;}
//int fplus(int x,int y){return x+y>=mod?x+y-mod:x+y;}
//void Fplus(int&x,int y){x=fplus(x,y);}
//int fminus(int x,int y){return x-y<0?x+mod-y:x-y;}
//void Fminus(int&x,int y){x=fminus(x,y);}

const int mod=1e9+7,N=200005;
int n,a[N],ans;
map<int,int>mp;

bool Med;
signed main() {
    fprintf(stderr,"%.3lfMb\n",(&Mbe-&Med)/1024./1024.);
    for(int T=read();T--;){
        ans=0;
        map<int,int>().swap(mp);
        n=read();
        rep(i,1,n)a[i]=read();
        mp[0]=1;
        int x=0;
        rep(i,1,n){
            mp[x]=(mp[x]*3+mp[a[i]^x]*2)%mod;
            x^=a[i];
        }
        for(pii p:mp)ans=(ans+p.se)%mod;
        printf("%lld\n",ans);
    }
    return 0;
}