题面:
CDQ裸题。
上洛谷群借了个权限号AC了。
// It is made by XZZ#include#include #define il inline#define rg register#define vd void#define sta statictypedef long long ll;il int gi(){ rg int x=0,f=1;rg char ch=getchar(); while(ch<'0'||ch>'9')f=ch=='-'?-1:f,ch=getchar(); while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*f;}const int maxn=500001,maxm=200001<<1;struct yyb{int x,y,y2,id,sao;}s[maxm],_s[maxm];int ans[maxn],n,m,q;il bool cmp(const yyb&a,const yyb&b){return a.x==b.x?a.id==-1:a.x >1,i=l,j=mid+1,_i=mid+1,_j=r+1; CDQ(l,mid),CDQ(mid+1,r); while((i^_i)&&(j^_j)) if(cmp(s[i],s[j])){ _s[++k]=s[i]; if(s[i].id==-1)BIT::Upd(s[i].y,s[i].sao); ++i; }else{ _s[++k]=s[j]; if(s[j].id!=-1)ans[s[j].id]+=BIT::Query(s[j].y,s[j].y2)*s[j].sao; ++j; } while(j^_j){ _s[++k]=s[j]; if(s[j].id!=-1)ans[s[j].id]+=BIT::Query(s[j].y,s[j].y2)*s[j].sao; ++j; } for(rg int p=l;p