话说这道题是一道不折不扣的二维树状数组的水题,可是对于我这种菜鸟中的vip来说,却还是纠结了很久很久。。留下做个模板吧。。。。。
题目:
Yifenfei is a romantic guy and he likes to count the stars in the sky.
To make the problem easier,we considerate the sky is a two-dimension plane.Sometimes the star will be bright and sometimes the star will be dim.At first,there is no bright star in the sky,then some information will be given as "B x y" where 'B' represent bright
and x represent the X coordinate and y represent the Y coordinate means the star at (x,y) is bright,And the 'D' in "D x y" mean the star at(x,y) is dim.When get a query as "Q X1 X2 Y1 Y2",you should tell Yifenfei how many bright stars there are in the region
correspond X1,X2,Y1,Y2.
There is only one case.
Input
The first line contain a M(M <= 100000), then M line followed.
each line start with a operational character.
if the character is B or D,then two integer X,Y (0 <=X,Y<= 1000)followed.
if the character is Q then four integer X1,X2,Y1,Y2(0 <=X1,X2,Y1,Y2<= 1000) followed.
Output
For each query,output the number of bright stars in one line.
Sample Input
5
B 581 145
B 581 145
Q 0 600 0 200
D 581 145
Q 0 600 0 200
Sample Output
ac代码:
分享到:
相关推荐
这是一道很不错的题目,即可以用线段树做也可以用树状数组,可谓经典。不过当然了线段树是比较难搞,而树状数组是极其简洁的,构造很简单,下面就分别来介绍一下两种方法...
二维树状数组 Trie树 二叉查找树 线段树 RMQ LCA+RMQ SB-Tree 数论 生成紧凑素数表 分解质因子 最大公约数 a^b mod n 扩张欧几里德算法 素数表质因子分解 Stirling公式 中国剩余定理 欧拉数(递推法)...
绘制太阳系行星轨道2D平面图,数据库中包含了行星数据,但是数据来源于百度搜集,不够精确
star manual is a manual for cmg software
视觉测量(V-STARS摄影测量系统) 立体视觉是由多幅图像(一般2幅)获取物体三维几何信息的方法
Stars1
Stars2
stars
按stars排序的论文-代码实现列表,每周更新
m3u8合并器 by stars-one.zip
StarCabinet, 开源的跨平台Github Stars管理分析工具
Baseball Stars 2 (USA) wiiware wad 格式wii 专用,可以放到SD卡内进行安装
Atom-atom-package-diff.zip,安装的Atom软件包与APM Stars之间的差异原子包差异,atom是一个用web技术构建的开源文本编辑器。
Android Five Stars Library Android Five Stars Library is a small library that helps developers add a "Rate My App" dialog to their applications. It's called "Five Stars" because the dialog has a ...
当前版本的STARS是基于从数字到Numpy的重构。 此版本应可在以下平台上使用 Linux 视窗 苹果电脑 安装 使用Conda(所有平台) git clone https://github.com/sjsrey/stars.git 安装 conda create -n stars python...
在Github中stars数最多的Go Web框架集合
scor-stars 基于vue的评分星星组件,例如5:glowing_star: 安装 方法一: npm install scor-stars --save import stars from 'scor-stars' 方法二: [removed] 使用 不管您是在.vue文件中使用或者是在原生的html中...
上传一个用vc制作的闪闪的红星,能够自定义背景和闪烁速度。你们可以
CMG-STARS使用指南适用于初学者,是PDF文件,英语也比较容易看懂。
city of stars.docx