#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 20000;
typedef long long ll;
int n;
int bit[maxn<<1];
int crt[maxn<<1];
void add(int i,int x){
while(i<=(maxn<<1)){ //切记,这里不是 i <= n; 因为是用 x 坐标来设点的
bit[i] +=x;
i += i&(-i);
}
}
ll sum(int x){
ll res=0;
while(x>0){
res +=bit[x];
x -= x&(-x);
}
return res;
}
int main()
{
// freopen("in.txt","r",stdin);
int x,y;
while(~scanf("%d",&n)){
memset(crt,0,sizeof(crt));
memset(bit,0,sizeof(bit));
for(int i=1;i<=n;++i){
scanf("%d%d",&x,&y);
ll ans = sum(x+1);
crt[ans]++;
add(x+1,1);
}
for(int i=1;i<=n;++i){
printf("%d\n",crt[i-1]);
}
}
return 0;
}
POJ 2352 Stars
最新推荐文章于 2020-08-18 09:13:34 发布