当前位置:网站首页>【学习笔记】线段树选做
【学习笔记】线段树选做
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
感性理解的话,如果你在贪心的最优方案上换的越多,方案也就更劣 。
证明略了 。
边栏推荐
- Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
- 关于 appium 如何关闭 app (已解决)
- [爬虫]使用selenium时,躲避脚本检测
- Practical example of propeller easydl: automatic scratch recognition of industrial parts
- - Oui. Migration entièrement automatisée de la Sous - base de données des tableaux d'effets sous net
- visual stdio 2017关于opencv4.1的环境配置
- 【无标题】
- [疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
- ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型
- ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
猜你喜欢

Sed of three swordsmen in text processing

Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)

Leetcode question brushing: binary tree 26 (insertion operation in binary search tree)

高瓴投的澳斯康生物冲刺科创板:年营收4.5亿 丢掉与康希诺合作

How to continue after handling chain interruption / sub chain error removed from scheduling

MySQL master-slave replication

How to apply @transactional transaction annotation to perfection?

opencv的四个函数

基于NeRF的三维内容生成

聊聊Redis缓存4种集群方案、及优缺点对比
随机推荐
【无标题】
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
认养一头牛冲刺A股:拟募资18.5亿 徐晓波持股近40%
HZOJ #236. Recursive implementation of combinatorial enumeration
Design and implementation of communication protocol
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
@What is the difference between resource and @autowired?
人均瑞数系列,瑞数 4 代 JS 逆向分析
@Resource和@Autowired的区别?
Practical example of propeller easydl: automatic scratch recognition of industrial parts
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
mysql怎么创建,删除,查看索引?
How to reset Google browser? Google Chrome restore default settings?
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
【无标题】
Go语言学习笔记-结构体(Struct)
PHP调用纯真IP数据库返回具体地址
How to apply @transactional transaction annotation to perfection?
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
How to reset Firefox browser