- 题解
- 2018-09-14 19:24:32 @
#include <cstdio>
#include <cstring>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=15005,M=32010;
struct node{
int x,y;
}a[N];
int n,len[N],ans[N],tree[M];
int lowbit(int x){
return x&(-x);
}
int sum(int x){
int ans=0;
while (x>0){
ans+=tree[x];x-=lowbit(x);
}
return ans;
}
int add(int x){
while (x<M){
tree[x]++;x+=lowbit(x);
}
}
bool cmp(node m,node n){
return (m.x<n.x)||(m.x==n.x && m.y<n.y);
}
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d%d",&a[i].x,&a[i].y);
}
sort(a+1,a+n+1,cmp);
for (int i=1;i<=n;i++){
ans[sum(a[i].y)]++;
add(a[i].y);
}
for (int i=0;i<n;i++) printf("%d\n",ans[i]);
return 0;
}
1 条评论
-
PA_lotusbl LV 5 MOD @ 2018-10-15 19:06:24
我两级~(≧▽≦)/~啦啦啦
- 1