题目描述 给你一个序列,支持三种操作: $0\ x\ y\ t$ :将 $[x,y]$ 内大于 $t$ 的数变为 $t$ :$1\ x\ y$ :求 $[x,y]$ 内所有数的最大值:$2\ x\ y$ :求 $[x,y]$ 内所有数的和. 多组测试数据,$\sum n,\sum m\le 10^6$ 题解 线段树区间最值操作 对于线段树上的一个节点,维护对应区间的:最大值 $mx$ .最大值个数 $c$ 及严格次大值 $se$ .那么对于一次区间最小值操作: 如果 $t\ge mx$ ,则这个…
Gorgeous Sequence Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2150    Accepted Submission(s): 594 Problem Description There is a sequence a of length n. We use ai to denote the i-th elemen…
http://www.shuizilong.com/house/archives/hdu-5306-gorgeous-sequence/ Gorgeous Sequence Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 440    Accepted Submission(s): 87 Problem Description Th…
Code: #include<algorithm> #include<cstdio> #include<cstring> #define ll long long #define setIO(s) freopen(s".in","r",stdin) #define maxn 2000000 #define lson (now<<1) #define rson ((now<<1)|1) using names…
2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A with n numbers. Then he make…
Wow! Such Sequence! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3808 Accepted Submission(s): 1079 Problem Description Recently, Doge got a funny birthday present from his new friend, Protein…
D. The Child and Sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/438/problem/D Description At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important…
Problem Description Recently, Doge got a funny birthday present from his new friend, Protein Tiger from St. Beeze College. No, not cactuses. It's a mysterious blackbox. After some research, Doge found that the box is maintaining a sequence an of n nu…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=6047 题目: Maximum Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 90    Accepted Submission(s): 44 Problem Description Steph is extremely o…
At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks. Fortunately, Picks remembers how to repair the sequence. Initi…
Rikka with Sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5828 Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A wi…
题目链接:hdu 4983 Wow! Such Sequence! 题目大意:就是三种操作 1 k d, 改动k的为值添加d 2 l r, 查询l到r的区间和 3 l r. 间l到r区间上的所以数变成近期的斐波那契数,相等的话取向下取. 解题思路:线段树.对于每一个节点新增一个bool表示该节点下面的位置是否都是斐波那契数. #include <cstdio> #include <cstring> #include <cstdlib> #include <algo…
题目链接: NanoApe Loves Sequence Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 262144/131072 K (Java/Others) Problem Description NanoApe, the Retired Dog, has returned back to prepare for the National Higher Education Entrance Examination! In…
题目链接:Codeforces 486E LIS of Sequence 题目大意:给定一个数组.如今要确定每一个位置上的数属于哪一种类型. 解题思路:先求出每一个位置选的情况下的最长LIS,由于開始的想法,所以求LIS直接用线段树写了,没有改,能够用 log(n)的算法直接求也是能够的.然后在从后向前做一次类似LIS.每次推断A[i]是否小于f[dp[i]+1],这样就能够确定该位 置是否属于LIS序列. 然后为第三类的则说明dp[i] = k的仅仅有一个满足. #include <cstdi…
D. The Child and Sequence   At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite sequence of Picks. Fortunately, Picks remembers how t…
题意:一个初始为0的数组,支持三种操作:1.向第k个数添加d,(|d| < 2^31);2.把[l, r]区间内的数字都换成与它最相近的Fibonacci数;3.询问[l, r]区间的和. 思路:初始化Fibonacci数组,longlong 类型内90个就够用了. 线段树区间查询,用lazy标记, sgt[]记录线段树各个节点的区间和, fib_num_sum[]记录与各个叶子节点当前值最接近的Fibonacci数,传递到区间fib_num_sum[]就是区间Fibonacci数的和. 操作1…
题目链接 给m个数, n个操作, 一个数列, 初始为空.一共有3种操作, 在数列末尾加0, 加1, 或删除位置为a[i]的数, a[i]为初始给的m个数, 如果a[i]大于数列长度, 那么什么也不发生. 求最后的数列. 用线段树, 因为最多只有n个操作, 也就是说最后的01串最大长度为n, 那么可以用一个变量now表示当前插入的话应该插入到哪个位置, 每插入一个数, now就加1,并且now最终不会超过n. 删除操作的话, 递归的进行, 如果sum[rt<<1]大于要删除的下标那么就往左儿子递…
题意 题目链接 单点修改,区间mod,区间和 Sol 如果x > mod ,那么 x % mod < x / 2 证明: 即得易见平凡, 仿照上例显然, 留作习题答案略, 读者自证不难. 反之亦然同理, 推论自然成立, 略去过程Q.E.D., 由上可知证毕. 然后维护个最大值就做完了.. 复杂度不知道是一个log还是两个log,大概是两个吧(线段树一个+最多改log次.) #include<bits/stdc++.h> #define Pair pair<int, int&g…
题目链接 问题在于操作二.操作二可以拆分成:区间加\(C\).区间(对\(0\))取\(\max\). 注意到操作一的\(C\)都是非负数,即数列中不会出现负数,所以我们直接维护最小值和最小值出现的次数即可得到操作三的答案. 操作一的赋值和操作二的加都是模板.但是取\(\max\)会影响最小值的个数(某些\(>mn\)的值可能一起变成最小值). 参照吉司机线段树,我们还需要维护严格次小值\(se\). 进行\(\max(v)\)操作时,若\(mn[rt]\geq v\),则直接返回:若\(se[…
题目描述 维护一个长度为N的序列a,现在有三种操作: 1)给出参数U,V,C,将a[U],a[U+1],...,a[V-1],a[V]都赋值为C. 2)给出参数U,V,C,对于区间[U,V]里的每个数i,将a[i]赋值为max(a[i]+C,0). 3)给出参数U,V,输出a[U],a[U+1],...,a[V-1],a[V]里值为0的数字个数. 输入 第一行包含两个正整数N,M(1<=N,M<=300000),分别表示序列长度和操作个数. 第二行包含N个整数,其中第i个数表示a[i](0&l…
http://acm.hdu.edu.cn/showproblem.php?pid=5306 给一个数组,m次操作: 1:l r x,将a[i](l<=i<=r)=min(a[i],x) 2:l r,求区间最大值. 3:l r,求区间和. 吉司机线段树,论文题,论文讲的很详细了. 维护一个最大值mx和次大值se,分类讨论: 当mx<=x显然没有影响. 当se<x<mx打标记修改区间. 否则暴力递归两个儿子. 通过奇(看)技(论)淫(文)巧能够证明复杂度是O(mlogn). (…
这个题目是Segment-Tree-beats的论文的第一题. 首先我们考虑下这个问题的不同之处在于,有一个区间对x取max的操作. 那么如何维护这个操作呢? 就是对于线段树的区间,维护一个最大值标记,最大值出现次数,以及严格次大值. 接下来考虑处理操作. 首先如果x>maxv[o]证明已经是无所谓的,所以应该直接放弃. 如果v处于semx[o]<x<maxv[o],证明只有最大值需要被修改. 其他的情况就继续向下递进就可以了. 那么我们证明一下为什么这么做复杂度是对的. 首先,如同论文…
题意:对数列有三种操作: Print operation l, r. Picks should write down the value of . Modulo operation l, r, x. Picks should perform assignment a[i] = a[i] mod x for each i (l ≤ i ≤ r). Set operation k, x. Picks should set the value of a[k] to x (in other words…
传送门 题目大意: 给你一个序列,要求在序列上维护三个操作: 1)区间求和 2)区间取模 3)单点修改 这里的操作二很讨厌,取模必须模到叶子节点上,否则跑出来肯定是错的.没有操作二就是线段树水题了. 既然必须模到叶子节点,那我们就模咯. 显然,若$b<c$,则$b%c=b$. 因此我们同时维护一个区间最大值,若某区间内最大值小于模数,就把该分支剪掉. 若$a=b%c$,那么肯定有$a \leq \frac{b}{2}$成立. 也就是说,一个数最多被模$\log_2 x$次.总的时间复杂度为$O(…
http://acm.hdu.edu.cn/showproblem.php?pid=5306 (题目链接) 题意 区间取$min$操作,区间求和操作,区间求最值操作. Solution 乱搞一通竟然AC了= =,具体参考吉如一论文.蒯一发上来方便自己以后看嘿嘿. 对线段树中的每一个节点除了维护区间最值和区间和以外,还要额外维护区间中的最大值$ma$,严格次大值$se$以及最大值个数$t$. 现在假设我们要让区间$[L,R]$对$x$取$\min$,我们先在线段树中定位这个区间,对定位的每一个节点…
[BZOJ4355]Play with sequence Description 维护一个长度为N的序列a,现在有三种操作: 1)给出参数U,V,C,将a[U],a[U+1],...,a[V-1],a[V]都赋值为C. 2)给出参数U,V,C,对于区间[U,V]里的每个数i,将a[i]赋值为max(a[i]+C,0). 3)给出参数U,V,输出a[U],a[U+1],...,a[V-1],a[V]里值为0的数字个数. Input 第一行包含两个正整数N,M(1<=N,M<=300000),分别…
分析:这个题和bc round 73应该是差不多的题,当时是zimpha巨出的,那个是取phi,这个是开根 吐槽:赛场上写的时候直接维护数值相同的区间,然后1A,结果赛后糖教一组数据给hack了,仰慕 由于是开根,所以存在两个数刚开始差为1,加上某数再开根依旧是差1,这样维护相同数区间的就没用了 比如(2,3) +6-->(8,9)开根-->(2,3)如果全是这样的操作,即使维护相同的数,每次开根的复杂度都是O(N),不T才怪 这样只需要维护区间最大值最小值,当差1的时候,看看是否开根后还是差…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5828 给你n个数,三种操作.操作1是将l到r之间的数都加上x:操作2是将l到r之间的数都开方:操作3是求出l到r之间的和. 操作1和3就不说了,关键是开方操作. 一个一个开方,复杂度太高,无疑会T.所以我们来剪枝一下. 我们可以观察,这里一个数最多开方4,5次(loglogx次)就会到1,所以要是一段区间最大值为1的话,就不需要递归开方下去了.这是一个剪枝. 如果一段区间的数都是一样大小(最大值等于…
题目链接:http://codeforces.com/problemset/problem/438/D 给你n个数,m个操作,1操作是查询l到r之间的和,2操作是将l到r之间大于等于x的数xor于x,3操作是将下标为k的数变为x. 注意成段更新的时候,遇到一个区间的最大值还小于x的话就停止更新. #include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef __…
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has an array A with n numbers. Then he makes m operations on it. There are three ty…