#include<cstdio> #include<cstring> #define N 32010 using namespace std; int C[2*N],ans[N],n; int lowbit(int pos) { return pos&(-pos); } int Sum(int pos) { int sum=0; while (pos>0){ sum+=C[pos]; pos-=lowbit(pos); } return sum; } void modify(int pos,int add) { while (pos<=N){ C[pos]+=add; pos+=lowbit(pos); } } int main() { int cnt,i,x,y; while (scanf("%d/n",&n)!=EOF){ memset(ans,0,sizeof(ans)); memset(C,0,sizeof(C)); for (i=0;i<n;i++){ scanf("%d%d",&x,&y); cnt=Sum(x+1); ans[cnt]++; modify(x+1,1); } for (i=0;i<n;i++) printf("%d/n",ans[i]); } return 0; } /* 树状数组是从1开始的,切记切记~ */ 给出的y是递增的。树状数组是从1开始。