题目:http://codeforces.com/contest/1093/problem/G 只好看看题解:https://codeforces.com/blog/entry/63877 主要是把绝对值符号消掉,变成枚举正负.因为答案不会变差,所以不用管符号应该是什么,直接对应地取 max . min 即可. #include<cstdio> #include<cstring> #include<algorithm> #define ls Ls[cr] #define…
[CF1093G]Multidimensional Queries 题目大意: \(k(k\le5)\)维空间中有\(n(n\le2\times10^5)\)个点.\(m\)次操作,操作包含一下两种: 将第\(i\)个点改为\((b_1,b_2,\ldots,b_k)\). 询问编号在\([l,r]\)内的所有点对中,曼哈顿距离的最大值. 思路: 枚举每一维坐标对答案的贡献的符号是正还是负,总共\(2^{k-1}\)种情况.每种情况用线段树维护最大/最小值.询问时在每棵线段树上查询区间最大值-区…
分析 非常有趣的一道题. 式子中的绝对值很难处理,但是我们发现: \[\sum_{i=1}^{k}|a_{x,i}-a_{y,i}|=\sum_{i=1}^{k}max(a_{x,i}-a_{y,i},a_{y,i}-a_{x,i})=max\{\sum_{i=1}^{k}c_ia_{x,i}-\sum_{i=1}^{k}c_ia_{y,i}\}\] 其中\(c\)是所有长度为\(k\)的只由\(-1\)和\(1\)组成的数列,共有\(2^k\)种. 所以我们可以对于每一种\(c\)维护一棵支持…
描述 A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of endurance. For every attack of our secret weapon,…
Can you answer these queries? Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5195 Description A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapo…
                                                                                                              1082 - Array Queries Time Limit: 3 second(s) Memory Limit: 64 MB Given an array with N elements, indexed from 1 to N. Now you will be given…
题目链接:https://vjudge.net/problem/HDU-4027 A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of endurance. F…
传送门Can you answer these queries? 题意:线段树,只是区间修改变成 把每个点的值开根号: 思路:对[X,Y]的值开根号,由于最大为 263.可以观察到最多开根号7次即为1,则当根号次数大于等于7时,这段区间值为R-L+1,还有一点是L可能大于R. 以下来自鸟神:(真是强啊) 据这一性质,我们可以得到一种解决方案:对于修改,我们对于区间内的数不全为1的区间更新,直到遇到区间内的数全部为1的区间或者叶子结点为止.这样只要使用线段树,维护区间和的信息即可.  #inclu…
链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowercase Latin letters and q queries for this string. Recall that the substring s[l;r] of the string s is the string slsl+1-sr. For example, the substrings…
题目 线段树 简单题意: 区间(单点?)更新,区间求和  更新是区间内的数开根号并向下取整 这道题不用延迟操作 //注意: //1:查询时的区间端点可能前面的比后面的大: //2:优化:因为每次更新都是开平方,同一个数更新有限次数就一直是1了,所以可以这样优化 #include <stdio.h> #include<math.h> #define N 100010 #define LL __int64 #define lson l,m,rt<<1 #define rso…