HDU 1556 Color the ball 很典型的更新区间查找点的题(线段树树状数组两种解法)
来源:互联网 发布:淘宝网实拍保护网址 编辑:程序博客网 时间:2024/06/03 22:02
这道题应该说是线段树和树状数组简单的应用吧!都是用到了基本的功能更新区间查找点!
当使用线段树时,不想原来更新点查找区间那么简单,这里需要在结构体内另外添加一个lnc用来记录更新区间时正好覆盖到该区域时的改变值!然而在查找区间过程中当所查找的区间并不是给定的区间时,需要把给定的区间的sum值进行更新改变!并且也把该子区间的调用update进行更新,这样才能维护一个更新区间查找区间的线段树!
用树状数组时需要注意此时read(i)就是读取下表为i的值为read(i)!
注意数组尽量开大点!避免出现wa或是re!
下面是ac代码给大家参考:
线段树做法:
树状数组做法:
哈哈保持激情加油了!
- HDU 1556 Color the ball 很典型的更新区间查找点的题(线段树树状数组两种解法)
- HDU~1556 Color the ball(线段树区间更新||树状数组)
- HDU 1556 Color the ball (线段树|树状数组,区间更新)
- HDu 1556 Color the ball【线段树&&树状数组】区间更新,单点查询
- HDU1556:Color the ball(线段树区间更新单点求值)&&树状数组解法
- hdoj Color the ball 1556 (线段树&&树状数组 区间值更新)
- HDU 1556 Color the ball(线段树区间更新)
- HDU 1556-Color the ball(线段树区间更新)
- HDU 1556 Color the ball【树状数组+区间更新】
- HDU 1556 Color the ball(树状数组区间更新)
- HDU 1556 Color the ball 树状数组-区间更新-模板
- HDU 1556 Color the ball(线段树的区间更新【注释】)
- HDU 1556 Color the ball(线段树|树状数组)
- hdu 1556 Color the ball (树状数组||线段树成段更新)
- hdoj 1556 Color the ball 【线段树 + lazy区间更新】 【树状数组】
- 线段树 (更新区间查询点)Color the ball
- Hdu oj 1556 Color the ball(树状数组区间更新转单点更新)
- HDU 1556 Color the ball 线段树更新区间查点
- gnochm 安装
- 使用C++标准库实现文件的读取
- OPhone自定义UI控件的实现原理解析
- 對Win7的VPN客戶端“加密”的理解
- Linux下载工具Curl详解
- HDU 1556 Color the ball 很典型的更新区间查找点的题(线段树树状数组两种解法)
- 软件水平 小结
- 【动态树】poj2763
- 100921 中软实训之调试、〈MFC WINDOWS程序设计〉之鼠标画图
- 权限系统概要
- C#扩展方法简单入门
- 2DRenderEx进度~
- MobilePreview框架设计
- 二十四句