#include <bits/stdc++.h>
using namespace std;
#define maxn 32005
int N;
int sum[maxn] , level[maxn];
inline int lowbit(int x)
{
return x & (-x);
}
int get_sum(int x)
{
int s = 0;
while(x > 0)
{
s += sum[x];
x -= lowbit(x);
}
return s;
}
void update(int x)
{
while(x < maxn)
{
sum[x]++;
x += lowbit(x);
}
}
int main()
{
while(~scanf("%d" , &N))
{
memset(sum, 0, sizeof(sum));
memset(level, 0, sizeof(level));
int x , y;
int t = N;
while(N--)
{
cin>>x>>y;
x++;
level[get_sum(x)]++;
update(x);
}
for(int i=0; i<t; i++)
cout<<level[i]<<endl;
}
return 0;
}
poj 树状数组入门 2352
最新推荐文章于 2019-08-09 19:56:34 发布