2019icpc南昌邀请赛F(线段树)】的更多相关文章

题目链接:https://nanti.jisuanke.com/t/40258 题意:给长为n的数组a,有m次操作,包括单点修改和查询F(l,r),其值为所有f(i,j)的异或和,l<=i<=j<=r,即 其中 (n,m<=1e5). 思路:这种题可以用线段树来进行修改和查询,但需要先化简.对于l<=x<=r,包括ax的区间有(r-x+1)*(x-l+1)个,注意到当区间长为偶数时,改值恒为偶数,那么也就是说ax出现偶数次,那么查询结果为0.当区间长度为奇数时,若x与l…
题目链接 题意:求一个序列的最大的(区间最小值*区间和) 线段树做法:用单调栈求出每个数两边比它大的左右边界,然后用线段树求出每段区间的和sum.最小前缀lsum.最小后缀rsum,枚举每个数a[i],设以a[i]为最小值的区间为[l,r] 若a[i]>0,则最优解就是a[i]*([l,r]的区间和),因为[l,r]上的数都比a[i]大. 若a[i]<0,则最优解是a[i]*([l,i-1]上的最小后缀+a[i]+[i+1,r]上的最小前缀),在线段树上查询即可. 复杂度$O(nlogn)$…
Max answer Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value of the intervals in her array…
https://codeforces.com/contest/1099/problem/F 题意 一颗n个节点的树上,每个点都有\(x[i]\)个饼干,然后在i节点上吃一个饼干的时间是\(t[i]\),有n-1条边,每条边有边权w为经过一条边所需时间,你从树根开始先手向下走,然后对手割掉你所在节点到子节点的任意一条边,你可以在任何时间选择返回,在返回的过程中你可以选择性吃掉经过节点的饼干,问在双方最优的情况下,你最多能在T时间之内吃掉多少饼干并返回根节点(在足够时间返回根节点的情况下吃掉尽可能多…
题目链接 传送门 题面 思路 设\(x=\prod\limits_{i=l}^{r}a_i\)=\(\prod\limits_{i=1}^{n}p_i^{c_i}\) 由欧拉函数是积性函数得: \[ \begin{aligned} \phi(x)&=\phi(\prod\limits_{i=1}^{n}p_i^{c_i})&\\ &=\prod\limits_{i=1}^{n}\phi(p_i^{c_i})&\\ &=\prod\limits_{i=1}^{n}p_…
题意:给出n个点的权值,m次操作,操作为1时为询问,每次询问给出 l 和 r ,求 f(l,r).操作为0时为修改权值.f(l,r)=f(l,l)⊕f(l,l+1)⊕⋯⊕f(l,r)⊕f(l+1,l+1)⊕⋯f(l+1,r)⊕⋯⊕f(r,r)F(l,r)=f(l,l)⊕f(l,l+1)⊕⋯⊕f(l,r)⊕f(l+1,l+1)⊕⋯f(l+1,r)⊕⋯⊕f(r,r). 题解:首先多写算几个 l 到 r,可以发现当 r - l 时奇数的时候,f(l,r)为0:当 r - l 为偶数时,就是 l⊕l+2…
---恢复内容开始--- 1284: SP教数学 时间限制: 2 秒  内存限制: 128 MB提交: 24  解决: 4 题目描述 输入 输出 对于每组数据的2操作,输出一行对1e9 + 7取模的答案 样例输入 7 4 2 2 1 1 3 3 2 2 1 5 2 6 7 1 3 4 3 2 6 6 样例输出 6 3 2 提示 1 <=  n ,m <=10^5 一道很有趣的ST的题目,有趣在维护节点时用到了矩阵运算,减少了计算量. 首先对于矩阵运算法则,百度百科: 基本性质 乘法结合律: (…
题目链接:https://nanti.jisuanke.com/t/40254 题意: 思路: 这题要用到拉格朗日插值法,网上查了一下,找到一份讲得特别好的: -------------------------------------------------------- 以上关于拉格朗日插值法的理论转载自:https://blog.csdn.net/ftx456789/article/details/90750508 关于这道题的做法:这题给了x从0~n的n+1种取值,那么可以用O(n)来插值…
线段树+单调栈+前缀和--2019icpc南昌网络赛I Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value of the inter…
题目链接:https://nanti.jisuanke.com/t/38228 Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value…