#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<vector>
#include<ctime>
#include<queue>
#include<stack>
#include<unordered_map>
#include<set>
#define ld long double
#define ll long long
#define ull unsigned long long
#define ui unsigned int
namespace FastIO
{
template<typename T> inline void read(T&s)
{
s=0;char ch=getchar();
while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
bool tf=(ch=='-')&&(ch=getchar());
while((ch>='0')&&(ch<='9'))s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
s=(tf?-s:s);
}
template<typename T,typename... Args> inline void read(T&x,Args&...args){read(x),read(args...);}
template<typename T> inline void write(T x,char ch=' ')
{
if(x<0)x=-x,putchar('-');
static char st[25];int top=0;
do{st[top++]=x%10+'0',x/=10;}while(x);
while(top)putchar(st[--top]);
putchar(ch);
}
}
using namespace FastIO;
using namespace std;
#define mid (l+((r-l)>>1))
namespace WrongAnswer_90
{
int sum,l,r,n,x,y,cnt,a[1000001],root[1000001];
unordered_map<int,int> mp;
struct Node{int ls,rs,val;}t[21125001];
void change(int now,int from,int k,int val)
{
l=1,r=n+1;
while(l!=r)
{
t[now].val=t[from].val^val;
if(k<=mid)t[now].rs=t[from].rs,now=t[now].ls?t[now].ls:t[now].ls=++cnt,from=t[from].ls,r=mid;
else t[now].ls=t[from].ls,now=t[now].rs?t[now].rs:t[now].rs=++cnt,from=t[from].rs,l=mid+1;
}
t[now].val=t[from].val^val;
}
int ask(int now,int k)
{
sum=0,l=1,r=n+1;
while(l!=r)
{
if(!now)return sum;
if(k<=mid)sum^=t[t[now].rs].val,now=t[now].ls,r=mid;
else now=t[now].rs,l=mid+1;
}
sum^=t[now].val;
return sum;
}
inline void mian()
{
read(n);
for(int i=1;i<=n;++i)read(a[i]);
for(int i=n;i>=1;--i)
{
if(mp.find(a[i])==mp.end())root[i]=n+1;
else root[i]=mp[a[i]];
mp[a[i]]=i;
}
mp.clear();
for(int i=1;i<=n;++i)sum=root[i],root[i]=++cnt,change(root[i],root[i-1],sum,a[i]),a[i]^=a[i-1];
read(cnt);
while(cnt--)read(x,y),write(ask(root[y],y+1)^ask(root[x-1],y+1)^a[y]^a[x-1],'\n');
}
}
//#define LOCALJUDGE
signed main()
{
WrongAnswer_90::mian();
return 0;
}
MLE on #100
就我的水平看来已经到极限了
正解其实不需要可持久化
但是已经写了真的不想改了/kk/kk/kk
有没有哪位大佬帮忙卡卡