#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; }
时间: 2024-10-11 18:04:13