当前位置:网站首页>【学习笔记】树形dp
【学习笔记】树形dp
2022-07-15 09:43:00 【仰望星空的蚂蚁】
Nearest Leaf
The Chocolate Spree
Power Tree
Pairs of Paths
- sb数据结构题
- 暴力
- 分两种形态暴力
- 评分3000不过分吧
Nested Rubber Bands
- 巧妙的题目
- 菊花图显然是合法的
- 把菊花图拼起来也是合法的
- 手玩可以得到
- 若干菊花图拼起来的子图只能连一条边出去
- 等价于,菊花图的中心必须拼成一条链
- 毋宁称之为构造题
- 可以树形dp
- 注意细节
- 复杂度 O ( n ) O(n) O(n)
Distance Tree
- 巧妙的题目
- 假定其中一个端点是 1 1 1
- 另一个端点是 u u u
- 考虑二分答案 l l l
- 因为这样做比较顺
- 把 u u u求出来
- 然后考虑那些深度比 l l l大的叶子
- 把绝对值拆开就可以 O ( 1 ) O(1) O(1)判了
- 复杂度 O ( n log n ) O(n\log n) O(nlogn)
vscode好评- 不保证是正解。不保证和题解一样优秀。
Two-Paths
行百里者,半九十- 对不起我又要骂了
sb数据结构 - 倍增+暴力
- d p [ u ] dp[u] dp[u]表示从 u u u出发遍历完子树的最大贡献
- d p 2 [ u ] dp2[u] dp2[u]表示从 u u u出发遍历完整个子树的最大贡献
- d p [ u ] , d p 2 [ u ] dp[u],dp2[u] dp[u],dp2[u]是一个求和的形式
- 这启发我们用倍增+暴力统计答案
- 代码很恶心就不说了
vscode好评
边栏推荐
- leecode17电话号码的字母组合
- Interface test - process test supports batch parameter import, and the test efficiency is directly full!
- Unity judges whether the object is in front of the camera and the UI follows the 3D object
- Technology companies have opposed the shelving of the UK cybersecurity act
- Locust performance test 1 (understanding)
- Communication chat system based on 51 single chip microcomputer
- H5 start applet
- Getting started with jupyter notebook tutorial
- 【教程】idea插件translation翻译快捷键及翻译设置
- Basic database operations in MySQL
猜你喜欢

Charles的基本使用及教程

How to debug the dynamic code generated by C emit?

这段sql在pg执行会报错,Oracle没问题

MFC控件学习:图片(bmp/png)

. Net core uses imagesharp to generate pictures

Electric razor touch chip-dlt8t10s-jericho

【古月21讲】ROS入门系列(2)——发布者Publisher、订阅者Subscriber的编程实现+自定义话题消息编程实现

Smart breeding scheme based on Lora gateway

蔚来缘何没有产品主义?

【教程】idea插件translation翻译快捷键及翻译设置
随机推荐
小程序 拉起企业微信进群二维码
Stuck or deadlock events in the use of MySQL Library
Difference between factory mode and strategic mode
【数学建模暑期培训】Matlab之求代数方程的符号解和数值解
Spike project learning
流程测试
kali系统入门-Hping3的使用
暑期沉淀web学习——SQL注入基础(基础&数字型&字符型)
Technology companies have opposed the shelving of the UK cybersecurity act
Nvisual secondary development - Chapter 1 Introduction
h5 调起小程序
【redis】redis加锁的几种思路及试验
Smart breeding scheme based on Lora gateway
oracledb_ Exporter monitors Oracle, a very low intrusive monitoring scheme.
DEDECMS织梦更改include目录重命名后,后台属性编辑无法加载的解决方法
[advanced C language] - common string functions
Degree engine (XI): Audio loading
View CPU information mode
Today, I went to oppo for an interview and got numb...
Applet pulls up enterprise wechat group QR code