当前位置:网站首页>【学习笔记】线段树选做
【学习笔记】线段树选做
2022-07-07 10:59:00 【仰望星空的蚂蚁】
全是暴力
打线段树好累
Fibonotci
一看这个线性递推关系显然是矩阵乘法
码码码 。。。
呼 。。写完了 。
Two Permutations
序列 hash ?
毋宁称之为线段树维护序列 hash 值的好题
类比 Permutation 。本质在于将复杂状态用一个整数表示,这样复杂度更优 。
Strange Addition
显然线段树维护 dp 。
注意细节 。以及不要算重 。
如果实现精细的话可以不用去前导零。轻微卡常。
Strange Array
膜拜 wicton 。
这题做法没那么明显 。
考虑从 [i,i] 进行扩展
分区间奇偶性讨论
考虑一个 < a i <a_i <ai 的数和 > a i >a_i >ai 的数会抵消
把 a i a_i ai 看成 < a i <a_i <ai 和 > a i >a_i >ai 两种情况考虑两次,这样不会出现相等的元素
将 ≤ a i \leq a_i ≤ai 的数看成 1 1 1 , > a i >a_i >ai 的数看成 − 1 -1 −1
分别向左右扩展 ,找最大子段和 a n s ans ans ,贡献为 ⌊ a n s − 1 2 ⌋ \lfloor\frac{ans-1}{2}\rfloor ⌊2ans−1⌋
将 ≥ a i \geq a_i ≥ai 的数看成 1 1 1 , < a i <a_i <ai 的数看成 − 1 -1 −1
分别向左右扩展 ,找最大子段和 a n s ans ans ,贡献为 ⌊ a n s 2 ⌋ \lfloor\frac{ans}{2}\rfloor ⌊2ans⌋
码码码 。。。
呼 。。写完了 。
Phoenix and Memory
行百里者,半九十 。
首先贪心求一组方案
如果要得到不同的序列的话,一定存在 ( i , j ) (i,j) (i,j) ( i ≠ j ) (i\ne j) (i=j)使得 l i ≤ a j ≤ r i l_i\leq a_j\leq r_i li≤aj≤ri 并且 l j ≤ a i ≤ r j l_j\leq a_i\leq r_j lj≤ai≤rj
感性理解的话,如果你在贪心的最优方案上换的越多,方案也就更劣 。
证明略了 。
边栏推荐
- Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
- 非分区表转换成分区表以及注意事项
- Day22 deadlock, thread communication, singleton mode
- AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
- Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
- [crawler] avoid script detection when using selenium
- 认养一头牛冲刺A股:拟募资18.5亿 徐晓波持股近40%
- Blog recommendation | Apache pulsar cross regional replication scheme selection practice
- ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
- Sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
猜你喜欢
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
2022a special equipment related management (boiler, pressure vessel and pressure pipeline) simulated examination question bank simulated examination platform operation
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
Day-15 common APIs and exception mechanisms
Lingyunguang of Dachen and Xiaomi investment is listed: the market value is 15.3 billion, and the machine is implanted into the eyes and brain
DHCP 动态主机设置协议 分析
Day-19 IO stream
Polymorphism, final, etc
共创软硬件协同生态:Graphcore IPU与百度飞桨的“联合提交”亮相MLPerf
人均瑞数系列,瑞数 4 代 JS 逆向分析
随机推荐
免费手机号码归属地API查询接口
Go语言学习笔记-结构体(Struct)
2022 polymerization process test question simulation test question bank and online simulation test
【学习笔记】AGC010
Blog recommendation | Apache pulsar cross regional replication scheme selection practice
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
用mysql查询某字段是否有索引
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
《开源圆桌派》第十一期“冰与火之歌”——如何平衡开源与安全间的天然矛盾?
Design and implementation of communication protocol
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
Steps of building SSM framework
Day-19 IO stream
DHCP 动态主机设置协议 分析
test
HZOJ #240. Graphic printing IV
SSM框架搭建的步骤
What are the benefits of ip2long?
The difference between cache and buffer
xshell评估期已过怎么办