# BZOJ3262 : 陌上花开

#include<cstdio>
#include<algorithm>
#define N 100010
using std::sort;
int n,m,k,i,j,t1,t2,b[N],c[N],fin[N],bit[N<<1],pos[N<<1],T;
struct P{int x,y,z,v,t;}a[N];
inline bool cmpx(P a,P b){return a.x==b.x&&a.y==b.y?a.z<b.z:(a.x==b.x?a.y<b.y:a.x<b.x);}
inline bool cmpy(int x,int y){return a[x].y==a[y].y?a[x].z<a[y].z:a[x].y<a[y].y;}
inline void add(int x,int y){for(;x<=k;x+=x&-x)if(pos[x]<T)pos[x]=T,bit[x]=y;else bit[x]+=y;}
inline int sum(int x){int t=0;for(;x;x-=x&-x)if(pos[x]==T)t+=bit[x];return t;}
void solve(int l,int r){
if(l==r)return;
int mid=(l+r)>>1;
for(t1=0,i=l;i<=mid;i++)b[++t1]=i;
for(t2=0,i=r;i>mid;i--)c[++t2]=i;
sort(b+1,b+t1+1,cmpy),sort(c+1,c+t2+1,cmpy);
solve(l,mid),solve(mid+1,r);
}
int main(){
sort(a+1,a+n+1,cmpx);
for(i=1;i<=n;a[m].v++,i++)if(a[i].x!=a[m].x||a[i].y!=a[m].y||a[i].z!=a[m].z)a[++m]=a[i];
solve(1,m);
for(i=1;i<=m;i++)fin[a[i].t+a[i].v-1]+=a[i].v;
for(i=0;i<n;i++)printf("%d\n",fin[i]);
return 0;
}


posted @ 2015-01-23 23:46  Claris  阅读(236)  评论(0编辑  收藏  举报