如果只有一次询问,可以分治,每次考虑跨过中点的情况。预处理左半边后缀or和,右半边前缀or和,然后用two pointers求。发现前、后缀or和只会变化O(log a)次。用线段树维护,记录每个区间的答案,以及前、后缀or和(这O(log a)个段)。push_up和查询时,还用two point... ...
分类:
其他好文 时间:
2020-07-08 23:21:12
阅读次数:
78
题解: 大致就是先求出凸包 然后有一个性质就是我们枚举每条边 然后凸包上的点到边的距离是单峰函数(刚开始傻逼的写了点对点) 于是可以two-point-two 为什么是对的呢 因为对于最远点对 我们取一条平行于边的直线,那这条边到那个点的距离就是最远距离 所以这样就是对的 另外我发现求凸包的代码需要 ...
分类:
其他好文 时间:
2019-01-01 23:58:39
阅读次数:
290
题意 "题目链接" 给出一个序列,求出有多少区间满足$A[l] \oplus A[l+1] \oplus \dots \oplus A[r] = A[l] + A[l + 1] +\dots+ A[r]$ Sol 一个区间能满足要求一定是所有bit上最多只有一个1 这玩意儿显然有单调性,two po ...
分类:
其他好文 时间:
2018-10-18 10:48:23
阅读次数:
162
题解: 虽然是过了,不过做的十分智障 首先是有 2根 2 1 1 , 3根 1 1 1 这两种方法 然后考虑2 2 1 1 two-point-two没啥好说的 3 1 1 1 我很智障的以为数据范围是1e9 然后写了hash,刚开始还开错范围 把int换short int才卡过了空间 首先枚举 1 ...
分类:
其他好文 时间:
2018-05-01 12:31:13
阅读次数:
151
B(倍增) 题意: 分析: 先可以用two point预处理出以每个位置为起点的连续段<=k的下一个终点 然后对于每个询问,倍增跳就行了 时间复杂度O(nlogn) C(扫描线处理区间询问) 题意: 分析: 先容易考虑到莫队算法,合并用并查集就行,但删除就很不方便了,而且n高达1e6,所以就无法用莫 ...
分类:
其他好文 时间:
2018-04-03 19:11:08
阅读次数:
155
http://acm.hdu.edu.cn/showproblem.php?pid=5884 原来求一次哈夫曼可以有O(n)的做法。 具体是,用两个队列,一个保存原数组,一个保存k个节点合并的数值,然后每次选k个的时候,用two point在两个队列中选k个出来即可。 然后又把新的节点放去第二个队列 ...
分类:
其他好文 时间:
2017-08-23 20:10:05
阅读次数:
119
Can I use Chinese? <br/>这个题是一道二分题目 <br/>he question is a two-point question. <br/>题意很简单,不需要解释了 <br/>It is very simple, do not need to explain. <br/>但是 ...
分类:
其他好文 时间:
2017-06-16 17:33:42
阅读次数:
152
尺取法(two point)的思想不难,简单来说就是以下三步: 1。对r point在满足题意的情况下不断向右延伸 2。对l point前移一步 3. 回到1 two point 对连续区间的问题求解有其独到之处 复杂度为0(n) 很实用的 ...
分类:
其他好文 时间:
2017-03-18 18:18:16
阅读次数:
134
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:
You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional...
分类:
其他好文 时间:
2015-07-06 12:21:02
阅读次数:
117
DP类题目找到子问题(状态),然后找到转移方程,就OK#dp#likes matrixchain#according to two point's distance to recurrenceclass Solution: # @return a string def longest...
分类:
其他好文 时间:
2015-03-04 18:51:45
阅读次数:
122