
线段树
文章平均质量分 78
freezuoguan
这个作者很懒,什么都没留下…
展开
-
hdu 4288 Coder (2012 ACM/ICPC Asia Regional Chengdu Online)
题目一上来就是线段树树, 队友旻健当场A了, 这是我赛后写的。 首先要把x离散化, 就是把需要要操作到的x存起来, 排序, 计算出每个x排在第几位置。 线段树节点存的是: 1.num[p]:当前区间有多少个位置是有值的; 2.sum[i][p]: 当前区间mod 5 余i 的和; 转移方程 for( int i = 0; i 5; i++ ){ int ex =原创 2012-09-16 21:24:08 · 502 阅读 · 0 评论 -
hdu 4419 Colourful Rectangle (2012杭州区域赛 1010 )
扫描 + 线段树; 首先离散化y, 节点用二进制保存7种颜色的个数, #include #include #include #include using namespace std; #define M 20010 struct Line { int up, down, x, left, col; Line(){} Line( int a, int b, int c, in原创 2012-09-24 10:43:13 · 686 阅读 · 0 评论 -
SPOJ 1557. Can you answer these queries II (很强的线段树)
原题地址:https://www.spoj.com/problems/GSS2/ 题意:询问任意区间内,最大连续序列和(相等的值不重复计算),可以不选输出0; 这题可以说一眼看出是线段树了,可是怎么构造确实非常难. 现在假设线段树中的叶子为 s[i]. 每次更新 a[i]的时候,s[1] -s[i]区间内加上a[i];那么 s[1] = a[1] + a[2] + a[3] + ... +原创 2013-01-03 20:07:32 · 2235 阅读 · 0 评论 -
poj 3225 Help with Intervals( 区间替换和取反)
题目 :http://poj.org/problem?id=3225 #include #include #include #include #include #include #include using namespace std; #define M 65540<<1 #define inf 1LL<<60 #define ll long long struct Node {原创 2013-02-13 18:13:49 · 426 阅读 · 0 评论