水一下

#include <bits/stdc++.h>
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
using namespace std; const int MAXN = 111111;
int sum[MAXN<<2];
int n; void push_down(int rt, int len)
{
if(sum[rt] == 0) return;
sum[rt<<1] += sum[rt];
sum[rt<<1|1] += sum[rt];
sum[rt] = 0;
} void update(int L, int R, int l, int r, int rt)
{
if(L <= l && r <= R)
{
sum[rt]++;
return;
}
push_down(rt, r - l + 1);
int m = (l + r) >> 1;
if(m >= L) update(L, R, lson);
if(m < R) update(L, R, rson);
} void query(int l, int r, int rt)
{
if(l == r)
{
printf("%d%c", sum[rt], l == n? '\n':' ');
return;
}
push_down(rt, r - l + 1);
int m = (l + r) >> 1;
query(lson);
query(rson);
} int main()
{
// freopen("in.txt", "r", stdin);
while(~scanf("%d", &n) && n)
{
memset(sum, 0, sizeof(sum));
int m = n;
while(m--)
{
int a, b;
scanf("%d%d", &a, &b);
update(a, b, 1, n, 1);
}
query(1, n, 1);
}
return 0;
}

hdu 1556 Color the ball 线段树 区间更新的更多相关文章

  1. HDU.1556 Color the ball (线段树 区间更新 单点查询)

    HDU.1556 Color the ball (线段树 区间更新 单点查询) 题意分析 注意一下pushdown 和 pushup 模板类的题还真不能自己套啊,手写一遍才行 代码总览 #includ ...

  2. HDU 1556 Color the ball(线段树区间更新)

    Color the ball 我真的该认真的复习一下以前没懂的知识了,今天看了一下线段树,以前只会用模板,现在看懂了之后,发现还有这么多巧妙的地方,好厉害啊 所以就应该尽量搞懂 弄明白每个知识点 [题 ...

  3. hdu 1556 Color the ball(线段树区间维护+单点求值)

    传送门:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/3276 ...

  4. hdu 1556 Color the ball (线段树+代码详解)

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  5. hdu 1556 Color the ball 线段树

    题目链接:HDU - 1556 N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气 ...

  6. HDU 1556 Color the Ball 线段树 题解

    本题使用线段树自然能够,由于区间的问题. 这里比較难想的就是: 1 最后更新须要查询全部叶子节点的值,故此须要使用O(nlgn)时间效率更新全部点. 2 截取区间不能有半点差错.否则答案错误. 这两点 ...

  7. Color the ball 线段树 区间更新但点查询

    #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #inclu ...

  8. hdu1556Color the ball线段树区间更新

    题目链接 线段树区间更新更新一段区间,在更新区间的过程中,区间被分成几段,每一段的左右界限刚好是一个节点的tree[node].left和tree[node].right(如果不是继续分,直到是为止) ...

  9. (简单) HDU 1698 Just a Hook , 线段树+区间更新。

    Description: In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of ...

随机推荐

  1. tigervnc报错

    tigervnc报错

  2. https://www.jqhtml.com/30047.html strace + 命令: 这条命令十分强大,可以定位你程序到底是哪个地方出了问题

    https://www.jqhtml.com/30047.html 我的Linux手册 服务器 浏览数:72 2019-1-30 原文链接 基础安装 # CentOS sudo yum install ...

  3. coverage report

    转载:http://blog.sina.cn/dpool/blog/s/blog_7853c3910102yn77.html VCS仿真可以分成两步法或三步法, 对Mix language, 必须用三 ...

  4. IPMITool和其中常用的命令

    IPMITool和其中常用的命令 # ipmitool -I lanplus -H 10.1.83.14-U ##### -P ##### chassis power status # ipmitoo ...

  5. Ansible-快速启动

    Ansible是一款简单的运维自动化工具,只需要使用ssh协议连接就可以来进行系统管理,自动化执行命令,部署等任务. Ansible的特点 1.ansible轻量级无客户端agentless,只需要双 ...

  6. 痞子衡嵌入式:关于i.MXRT中FlexSPI外设lookupTable里配置Normal read的一个小误区

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是i.MXRT中FlexSPI外设lookupTable里配置Normal read的一个小误区. 关于串行四线NOR Flash,当其作 ...

  7. 第三方数据格式库protobuf

    protobuf初识 protobuf是一种高效的数据格式,平台无关.语言无关.可扩展,可用于 RPC 系统和持续数据存储系统. protobuf protobuf介绍 Protobuf是Protoc ...

  8. Go基础结构与类型07---简单的数据类型转换

    package main import ( "fmt" "strconv" ) /* 类型转换强化 整型和浮点型可以直接强制转换 字符串和数值的转换用strco ...

  9. return true 和 return false 和 return

    1.return false:相当于终止符,干了3件事,阻止默认行为,取消事件冒泡,以及停止回调执行立即返回: 2.return:停止回调执行立即返回: 3.return true:相当于执行符,继续 ...

  10. TensorRT 数据格式说明

    TensorRT数据格式说明 NVIDIA  TensorRT支持不同的数据格式.需要考虑两个方面:数据类型和布局. 数据类型格式 数据类型是每个单独值的表示.它的大小决定了数值的范围和表示的精度:分 ...