记录编号 |
582492 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[POJ 2352]数星星 |
最终得分 |
100 |
用户昵称 |
┭┮﹏┭┮ |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.004 s |
提交时间 |
2023-09-15 19:43:58 |
内存使用 |
0.65 MiB |
显示代码纯文本
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 5e4+10;
- int n;
- int ans[N],c[N];
- //树状数组
- struct made{
- int x,y;
- bool operator <(const made& z)const{
- if(x == z.x)return y < z.y;
- else return x < z.x;
- }//重载<运算符
- }a[N];
- void add(int x,int z){
- while(x <= 32001){//!!!
- c[x] += z;
- x += x&-x;
- }
- return;
- }
- int ask(int x){
- int ss = 0;
- while(x > 0){
- ss += c[x];
- x -= x&-x;
- }
- return ss;
- }
- int main(){
- freopen("starcount.in","r",stdin);
- freopen("starcount.out","w",stdout);
- scanf("%d",&n);
- for(int i = 1;i <= n;i++){
- scanf("%d%d",&a[i].x,&a[i].y);
- a[i].x++,a[i].y++;
- }
- sort(a+1,a+1+n);
- for(int i = 1;i <= n;i++){
- ans[ask(a[i].y)]++;
- add(a[i].y,1);
- }
- for(int i = 0;i < n;i++)
- printf("%d\n",ans[i]);
-
- return 0;
-
- }