当前位置:网站首页>【学习笔记】线段树选做
【学习笔记】线段树选做
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
感性理解的话,如果你在贪心的最优方案上换的越多,方案也就更劣 。
证明略了 。
边栏推荐
- What are the benefits of ip2long?
- Conversion from non partitioned table to partitioned table and precautions
- 2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
- 【无标题】
- Go语言学习笔记-结构体(Struct)
- PHP调用纯真IP数据库返回具体地址
- test
- Steps of building SSM framework
- COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~
- How to reset Google browser? Google Chrome restore default settings?
猜你喜欢

认养一头牛冲刺A股:拟募资18.5亿 徐晓波持股近40%

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

Cookie

.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst

ICLR 2022 | 基于对抗自注意力机制的预训练语言模型

Practical example of propeller easydl: automatic scratch recognition of industrial parts

Day-14 common APIs

Talk about four cluster schemes of redis cache, and their advantages and disadvantages

Visual stdio 2017 about the environment configuration of opencv4.1

leecode3. 无重复字符的最长子串
随机推荐
关于 appium 如何关闭 app (已解决)
ClickHouse(03)ClickHouse怎么安装和部署
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
[爬虫]使用selenium时,躲避脚本检测
聊聊Redis缓存4种集群方案、及优缺点对比
Day-15 common APIs and exception mechanisms
通过Keil如何查看MCU的RAM与ROM使用情况
【无标题】
DHCP 动态主机设置协议 分析
【从 0 开始学微服务】【01】什么是微服务
ip2long与long2IP 分析
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
HZOJ #235. 递归实现指数型枚举
飞桨EasyDL实操范例:工业零件划痕自动识别
Creation and assignment of graphic objects
[learn micro services from 0] [02] move from single application to service
Leetcode brush questions: binary tree 19 (merge binary tree)
【Presto Profile系列】Timeline使用
mysql怎么创建,删除,查看索引?
Design and implementation of communication protocol