#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int N;
int x,y;
int tree[33000];
int level[16000];
int lowbit(int t){return t&(-t);}
void update(int index)
{
while(index<33000)
{
tree[index]++;
index+=lowbit(index);
}
}
int getSum(int index)
{
int sum=0;
while(index>0)
{
sum+=tree[index];
index-=lowbit(index);
}
return sum;
}
int main()
{
setbuf(stdout,NULL);
while(scanf("%d",&N)!=EOF)
{
int i;
memset(tree,0,sizeof(tree));
memset(level,0,sizeof(level));
for(i=0;i<N;i++)
{
scanf("%d %d",&x,&y);
x++;
level[getSum(x)]++;
update(x);
}
for(i=0;i<N;i++)
{
printf("%d\n",level[i]);
}
}
return 0;
}
转载于:https://www.cnblogs.com/lonelycatcher/archive/2011/07/22/2113853.html