HDU——T 1556 Color the ball
http://acm.hdu.edu.cn/showproblem.php?pid=1556
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 23167 Accepted Submission(s): 11249
当N = 0,输入结束。
1 1
2 2
3 3
3
1 1
1 2
1 3
0
3 2 1
#include <algorithm>
#include <cstring>
#include <cstdio> using namespace std; const int N(+);
int n,a,b; int tr[N];
#define lowbit(x) (x&((~x)+1))
inline void Update(int pos,int x)
{
for(;pos<=n;pos+=lowbit(pos)) tr[pos]+=x;
}
inline int Query(int x)
{
int ret=;
for(;x;x-=lowbit(x)) ret+=tr[x];
return ret;
} int main()
{
for(;scanf("%d",&n)&&n;)
{
memset(tr,,sizeof(tr));
for(int i=;i<=n;i++)
{
scanf("%d%d",&a,&b);
Update(a,); Update(b+,-);
}
for(int i=;i<n;i++)
printf("%d ",Query(i));
printf("%d\n",Query(n));
}
return ;
}
HDU——T 1556 Color the ball的更多相关文章
- hdu 1556:Color the ball(第二类树状数组 —— 区间更新,点求和)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 1556:Color the ball(线段树,区间更新,经典题)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- HDU.1556 Color the ball (线段树 区间更新 单点查询)
HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #includ ...
- HDU 1556 Color the ball (数状数组)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 线段树(求单结点) hdu 1556 Color the ball
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 1556 Color the ball(区间更新,单点求值)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- HDU 1556 Color the ball(线段树区间更新)
Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...
- hdu 1556 Color the ball (线段树+代码详解)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- hdu 1556 Color the ball(线段树区间维护+单点求值)
传送门:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/3276 ...
随机推荐
- Android笔记——Activity中的数据传递案例(用户注冊)
1.创建程序activity_main: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/andro ...
- 里根上台时国债只占GDP的30%
学里根是刻舟求剑,关键是钱从哪来 5 里根主要靠借钱,这是冷战红利,美国打完二战国债占了GDP的120%,然后总量就没怎么增加,但战后GDP快速增长,结果国债占GDP的比例连续下降,打越战登月石油危 ...
- angularjs 模块化
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- Android sdk版本以及兼容性问题
Android:minSdkVersion —— 此属性决定你的应用能兼容的最低的系统版本,一盘情况是必须设置此属性. android:targetSdkVersion —— 此属性说明你当前的应用是 ...
- Android子线程创建Handler方法
如果我们想在子线程上创建Handler,通过直接new的出来是会报异常的比如: new Thread(new Runnable() { public void run() { Handler hand ...
- 1、Go base64编码
package main import ( "encoding/base64" "fmt") func main() { //标准base64编码 data:= ...
- bzoj1457: 棋盘游戏 SG函数 Nim
Code: #include<cstdio> #include<cstring> using namespace std; #define maxn 1003 #define ...
- Tp5 的 validate 自动验证
tp5自带的验证功能: 用法之一: $validate = new \think\Validate([ ['name', 'require|alphaDash', '用户名不能为空|用户名格式只能是字 ...
- NOIP2017普及组题
提高组死亡选手来AK普及(耗时两天). T1 #include<bits/stdc++.h> using namespace std; int A,B,C; int main() { ci ...
- Git学习笔记 2,GitHub常用命令
廖雪峰Git教程 莫烦Git教程 莫烦Git视频教程 文件三个状态,add之后从工作区(原始状态)到暂存区,commit之后从暂存区到版本库 工作区 暂存区 版本库 unstage stage mas ...