/*
虽然题目没说,但是读入有以下特点
由于,输入是按照按照y递增,如果y相同则x递增的顺序给出的
所以,可以利用入读的时间进行降为处理
*/

于是我们就得到了一个一维的树状数组解法啦

值得一提:坐标从0~32000,而树状数组是从1开始的

于是,我们对所有下标+1,数组开到32002就可以啦!

 #include <set>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN=,MAXX=;
int t[MAXX],n;
int lb(int i){return i&-i;}
void init(){memset(t,,sizeof(t));}
void add(int x,int v){for(int i=x;i<MAXX;i+=lb(i))t[i]+=v;}
int sum(int x){int ans=;for(int i=x;i;i-=lb(i))ans+=t[i];return ans;} int level[MAXN],x,y;
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)scanf("%d%d",&x,&y),level[sum(x+)]++,add(x+,);
for(int i=;i<n;i++)printf("%d\n",level[i]);
return ;
}

C++-POJ2352-Stars[数据结构][树状数组]的更多相关文章

  1. poj2352 Stars【树状数组】

    Astronomers often examine star maps where stars are represented by points on a plane and each star h ...

  2. [POJ2352] Stars(树状数组)

    传送门 先按照下标x排序,然后依次把y加入树状数组,边加入边统计即可. 注意下标re从零开始,需+1s ——代码 # include <iostream> # include <cs ...

  3. ACM数据结构-树状数组

    模板: int n; int tree[LEN]; int lowbit(int x){ return x&-x; } void update(int i,int d){//index,del ...

  4. POJ 2352 Stars(树状数组)

    Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30496   Accepted: 13316 Descripti ...

  5. 【poj 3167】Cow Patterns(字符串--KMP匹配+数据结构--树状数组)

    题意:给2个数字序列 a 和 b ,问按从小到达排序后,a中的哪些子串与b的名次匹配. a 的长度 N≤100,000,b的长度 M≤25,000,数字的大小 K≤25. 解法:[思考]1.X 暴力. ...

  6. hdu 1541/poj 2352:Stars(树状数组,经典题)

    Stars Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  7. POJ 2352 Stars(树状数组)题解

    Language:Default Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 52268 Accepted: 22 ...

  8. POJ 2352 stars (树状数组入门经典!!!)

    Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 54352   Accepted: 23386 Descripti ...

  9. Stars(树状数组)

    算法学习:http://www.cnblogs.com/George1994/p/7710886.html 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid ...

  10. Ultra-QuickSort (求逆序数+离散化处理)、Cows、Stars【树状数组】

    一.Ultra-QuickSort(树状数组求逆序数) 题目链接(点击) Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total ...

随机推荐

  1. es6转码和package.json中的配置

    在线实时转换 需要babel-register .babelrc中: { "presets": [ "es2015" ] } 项目中main.js配置: 前提是 ...

  2. java在子类中,调用父类中被覆盖的方法

    在java中,子类中调用与父类同名的方法(即父类中被覆盖的方法)用super来调用即可,下面是示例: 子类父类的定义 public class b { void show() { System.out ...

  3. openlayers轨迹匀速播放

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. MVC5+EF6 入门完整教程八:数据迁移

    https://www.cnblogs.com/miro/p/4164076.html

  5. simon effect (psychology experiment ) : build the function of wait4key()

    ## #the real experiment for simon effect #load the library which is our need import pygame import sy ...

  6. PP: Taking the human out of the loop: A review of bayesian optimization

    Problem: Design problem parameters consist of the search space of your model. Scientists design expe ...

  7. JVM的小理解

    1.开发人员编写Java代码(.java文件),然后将之编译成字节码(.class文件),再然后字节码被装入内存,一旦字节码进入虚拟机,它就会被解释器解释执行,或者是被即时代码发生器有选择的转换成机器 ...

  8. Python面向对象三大特性(封装、继承、多态)

    封装 类中把某些属性和方法隐藏起来,或者定义为私有,只在类的内部使用,在类的外部无法访问,或者留下少量的接口(函数)供外部访问:从上一篇文章中的私有属性与私有方法中的代码体现了该特性. class m ...

  9. jQuery---弹幕效果

    弹幕效果 <!doctype html> <html> <head> <meta charset="utf-8"> <titl ...

  10. Ubuntu系统测评

    首次使用ubuntun系统 华为云可以免费试用30天,嘻嘻,正好熟悉一下linux命令 1.登录 login: 先输入用户名:root 在输入密码:******** 这个是在配置云服务器的时候自己设置 ...