B - LCIS HDU - 3308 这个是一个很简单很明显的线段树的区间合并,不过区间合并的题目都还是有点难写,建议存个板子. #include <cstdio> #include <cstdlib> #include <algorithm> #include <iostream> #define inf 0x3f3f3f3f using namespace std; ; struct node { int l, r, rp, lp, len; int…
An easy problem B Time Limit: 2000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Problem Description N个数排成一列,每个数的大小为1或者0.有两种操作,第一种操作是把一段区间内的每个数异或1,第二种操作是询问区间内最长连续1的长度. Input 第一行一个整数N(1≤N≤100000),表示N个数.第二行N个数.接下来一行一个整数M(1≤M≤100000),表示…
D. Developing Game   Pavel is going to make a game of his dream. However, he knows that he can't make it on his own so he founded a development company and hired n workers of staff. Now he wants to pick n workers from the staff who will be directly r…
题意:给你一个数组,有两种操作,一种区间xor一个值,一个是查询区间xor的结果的种类数 做法一:对于一个给定的区间,我们可以通过求解线性基的方式求出结果的种类数,而现在只不过将其放在线树上维护区间线性基. 用线段树去维护区间合并 #include <bits/stdc++.h> using namespace std; const int maxn = 1e5; struct node { ],lazy,st; void init() { memset(bas,,sizeof(bas));…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3308 题目很好懂,就是单点更新,然后求区间的最长上升子序列. 线段树区间合并问题,注意合并的条件是a[mid + 1] > a[mid],写的细心点就好了. #include <iostream> #include <cstring> #include <cstdio> using namespace std; ; struct SegTree { int l , r…
最近开始线段树一段时间了,也发现了不少大牛的博客比如HH大牛  ,小媛姐.这个题目是我在看HH大牛的线段树专题是给出的习题,(可以去他博客找找,真心推荐)原本例题是POJ3667 Hotel 这个题目,是一个求连续空区间的情况,而hdoj这个题目是求给定区间单调连续的最大区间长度,两个题目思路很相似,将节点rt用sum[rt],lsum[rt],rsum[rt]来描述,分别表示rt对应区间即[l,r]内满足条件的区间的最大长度,从左边端点l开始满足条件的最大区间长度,从右边r开始向左的满足条件的…
LCIS Given n integers. You have two operations: U A B: replace the Ath number by B. (index counting from 0) Q A B: output the length of the longest consecutive increasing subsequence (LCIS) in [a, b].                  Input T in the first line, indic…
题意  给你一个数组  有更新值和查询两种操作  对于每次查询  输出相应区间的最长连续递增子序列的长度 基础的线段树区间合并  线段树维护三个值  相应区间的LCIS长度(lcis)  相应区间以左端点为起点的LCIS长度(lle)  相应区间以右端点为终点的LCIS长度(lri)  然后用val存储数组相应位置的值  当val[mid + 1] > val[mid] 的时候就要进行区间合并操作了 #include <cstdio> #include <algorithm>…
题意: Q a b 查询[a, b]区间的最长连续递增子序列的长度 U a b 将下表为a的元素更新为b 区间合并一般都有3个数组:区间最值,左区间最值和右区间最值 具体详见代码 #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 mx[MAXN<<2],…
看到讲课安排上 线段树有一节课"区间合并" 我是迷茫的 因为并没有见过 然后了解了一下题目 发现以前写过 还是很麻烦的树链剖分 大概是 解决带修改的区间查询"连续问题" 意思就是给一个数组 要对这个数组进行修改 然后进行区间查询 查询的一般是 l r 区间内的 连续xx 可能是LCIS 也可能只是连续的数字.. 解题的方法比较固定 由于是 连续性 相关 所以对于每个数组 维护它的左边与右边与全局的性质 例如紧靠左(右)边连续xx的长度和这个区间内连续xx的最长长度…