题目链接:http://codeforces.com/contest/284/problem/C 题意:就是给出3个操作 1)是将前i 个数加x 2)在数组最后添加一个数x 3)删除数组最后的那个数 题意:简单的线段树操作 #include <iostream> #include <cstring> #include <cstdio> using namespace std; typedef long long ll; const int M = 2e5 + 10; s…
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…
传送门 题目大意: 给你一个序列,要求在序列上维护三个操作: 1)区间求和 2)区间取模 3)单点修改 这里的操作二很讨厌,取模必须模到叶子节点上,否则跑出来肯定是错的.没有操作二就是线段树水题了. 既然必须模到叶子节点,那我们就模咯. 显然,若$b<c$,则$b%c=b$. 因此我们同时维护一个区间最大值,若某区间内最大值小于模数,就把该分支剪掉. 若$a=b%c$,那么肯定有$a \leq \frac{b}{2}$成立. 也就是说,一个数最多被模$\log_2 x$次.总的时间复杂度为$O(…
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…
[Codeforces 266E]More Queries to Array...(线段树+二项式定理) 题面 维护一个长度为\(n\)的序列\(a\),\(m\)个操作 区间赋值为\(x\) 查询\(\sum_{i=l}^r a_i(i-l+1)^k \mod 10^9+7\) \(n,m \leq 10^5,k \leq 5\) 分析 根据二项式定理 \[(i-l+1)^k=\sum_{j=0}^k (-1)^{k-j} C_{k}^j i^j(l-1)^{k-j}\] 那么 \(\begi…
[Codeforces 280D]k-Maximum Subsequence Sum(线段树) 题面 给出一个序列,序列里面的数有正有负,有两种操作 1.单点修改 2.区间查询,在区间中选出至多k个不相交的子区间,使得这至多k个子区间中数的和最大 分析 极其毒瘤的线段树,要维护18个变量 首先考虑查询k=1的情况,是常见的线段树模型.维护区间最大连续和,区间最大前缀和,区间最大后缀和.合并的时候分类讨论一下即可,这里不再赘述. 如果k>1怎么办呢.实际上可以贪心,每次取1个最大子区间,然后把子区…
codeforces 1217E E. Sum Queries? (线段树 传送门:https://codeforces.com/contest/1217/problem/E 题意: n个数,m次询问 单点修改 询问区间内最小的unbalanced number balanced number定义是,区间内选取数字的和sum sum上的每一位都对应着选取的数上的一位 否则就是unbalanced number 题解: 根据题意 如果区间存在unbalance number,那么一定存在两个数就可…
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…
题目链接: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…