题目
代码
#include<iostream>
#include<cstdio>
using namespace std;
const int N=32010;
int level[N];
int tr[N];
int n;
int lowbit(int x)
{
return x&-x;
}
void add(int x)
{
for(int i=x;i<N;i+=lowbit(i))
tr[i]++;
}
int sum(int x)
{
int res=0;
for(int i=x;i;i-=lowbit(i))
res+=tr[i];
return res;
}
int main()
{
cin>>n;
while(n--)
{
int x,y;
cin>>x>>y;
x++;
cout<<x<<endl;
add(x);
level[sum(x)]++;
}
printf(">>>>>>>>>>>\n");
for(int i=1;i<n;i++)
cout<<tr[i]<<endl;
printf("...........\n");
for(int i=1;i<=n;i++)
cout<<level[i]<<endl;
return 0;
}