整体二分模板(不带修)
POJ2104
code:
#include
#include
#include
#include
using namespace std;
const int MAXN=1e5+5;
int n,m,Ans[MAXN],b[MAXN],cg[MAXN];
struct ren{
int id,val;
ren(){};
ren(int I,int V){id=I,val=V;
}
};
vectora;
struct SG{
int l,r,sum;
}t[MAXN<<2];
struct que{
int id,l,r,k;
que(){};
que(int I,int L,int R,int K){id=I,l=L,r=R,k=K;
}
};
vectorq;
bool cmp(ren x,ren y){return x.val>1;
bui(p<<1,l,mid);bui(p<<1|1,mid+1,r);
}
void upd(int p,int x,int k){
if(t[p].l==t[p].r){t[p].sum+=k;return;}
int mid=(t[p].l+t[p].r)>>1;
if(x<=mid) upd(p<<1,x,k);
else upd(p<<1|1,x,k);
UPD(p);
}
int ask(int p,int L,int R){
if(t[p].l>=L&&t[p].r<=R) return t[p].sum;
int mid=(t[p].l+t[p].r)>>1,res=0;
if(L<=mid) res+=ask(p<<1,L,R);
if(R>mid) res+=ask(p<<1|1,L,R);
return res;
}
void sol(int L,int R,vectorv1,vectorv2){
if(L==R){
for(int i=0;i>1;
vectora1,a2;vectorb1,b2;
for(int i=0;i