判断 给定 坐标 左下角 有 多少个 坐标
因为 坐标 已经按 y 从小到大排列,就可以直接用树状数组了。。
#include<cstdio>
#include<cstring>
#define for if(0);else for
const int maxn=32005;
int cnt[maxn/2];
int c[maxn];
int lowbit(int x){
return x&(-x);
}
void update(int i){
while(i<=maxn){
c[i]++;
i+=lowbit(i);
}
}
int getsum(int i){
int sum=0;
while(i>0){
sum+=c[i];
i-=lowbit(i);
}
return sum;
}
int main(){
int n;
while(scanf("%d",&n)==1){
int x,y;
memset(cnt,0,sizeof(cnt));
for(int i=0;i<n;i++){
scanf("%d%d",&x,&y);
cnt[getsum(x+1)]++;
update(x+1);
}
for(int i=0;i<n;i++)printf("%d\n",cnt[i]);
}
}