#include #include using namespace std; #define impar first.first #define par first.second #define sent second #define BIT 10 #define info pair < pair < int , int > , bool > #define lson(x) ((x)<<1) #define rson(x) (((x)<<1)|1) #define NMAX 100007 #define MOD 4001 info t[BIT][3*NMAX]; int N,Q,L,i,x,type,a,b,pos,R,top,toi; int v[NMAX]; void Build(info t[],int n,int l,int r) { if (l==r) { ++t[n].par; return ; } int m=(l+r)>>1; Build(t,lson(n),l,m); Build(t,rson(n),m+1,r); t[n].par=t[lson(n)].par+t[rson(n)].par; t[n].impar=t[lson(n)].impar+t[rson(n)].impar; } void Send(info t[],int n) { if (!t[n].sent) return ; t[n].sent=false; swap(t[lson(n)].par,t[lson(n)].impar); t[lson(n)].sent^=1; swap(t[rson(n)].par,t[rson(n)].impar); t[rson(n)].sent^=1; } void Swap(info t[],int n,int l,int r) { if (l>1; if (L<=m) Swap(t,lson(n),l,m); if (R>m) Swap(t,rson(n),m+1,r); t[n].par=t[lson(n)].par+t[rson(n)].par; t[n].impar=t[lson(n)].impar+t[rson(n)].impar; } void Query(info t[],int n,int l,int r) { if (l>1; if (L<=m) Query(t,lson(n),l,m); if (R>m) Query(t,rson(n),m+1,r); } void Update(int pos,int va) { int j; for (j=0;j