/*
虽然题目没说,但是读入有以下特点
由于,输入是按照按照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. 关于牛客网C语言结构体位域(bit-fields)的一道题

    题目链接地址: https://www.nowcoder.com/questionTerminal/f4e20747a2dd4649bac0c028daa234f4 来源:牛客网 低地址字节 Byte ...

  2. Period 时间坑

    jdk1.8 的Period Period between = Period.between( LocalDate.parse("2018-01-01 00:00:00", Dat ...

  3. JMeter-查找元素

    参考文档:https://jmeter.apache.org/usermanual/hints_and_tips.html 有时很难使用变量或包含某个URL或参数的方法在“测试计划”树和元素中找到. ...

  4. openlayers按坐标点播放

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

  5. Beego的参数配置

    参数配置 beego 目前支持 INI.XML.JSON.YAML 格式的配置文件解析,但是默认采用了 INI 格式解析,用户可以通过简单的配置就可以获得很大的灵活性.默认配置解析 beego 默认会 ...

  6. 如何实现 List 集合的线程安全

    在实际项目开发中,List 集合较为常用,相比于数组,其提供了更多的方法,便于遍历.搜索.添加与移除.常见的有 ArrayList.Vector等.   关于ArrayList 中所周知,ArrayL ...

  7. Wannafly Winter Camp 2020 Day 5J Xor on Figures - 线性基,bitset

    有一个\(2^k\cdot 2^k\) 的全零矩阵 \(M\),给出 \(2^k\cdot 2^k\) 的 \(01\) 矩阵 \(F\),现在可以将 \(F\) 的左上角置于 \(M\) 的任一位置 ...

  8. 0级搭建类001-RedHat Enterprise Linux 8 安装(RHEL 8) 公开

    项目文档引子系列是根据项目原型,制作的测试实验文档,目的是为了提升项目过程中的实际动手能力,打造精品文档AskScuti. 项目文档引子系列目前不对外发布,仅作为博客记录.如学员在实际工作过程中需提前 ...

  9. VSCode常用插件之EditorConfig for vs code 使用

    更多VSCode插件使用请访问:VSCode常用插件汇总 当大家在公司工作时,不可能永远是一个人维护一个项目,当多个人参与一个项目,每个人使用的编辑器不一样,代码风格自然也不一样,那么如何让使用不同编 ...

  10. python接口自动化之pytest环境准备与入门(五)

    安装的pytest版本应该与安装的python版本对应,不然会有问题 (我的环境是python3.6与pytest4.5.0) 1.安装pytest pip install pytest==4.5.0 ...