当前位置:网站首页>[learning notes] double + two points
[learning notes] double + two points
2022-07-01 01:13:00 【Ants looking up at the starry sky】
Smile House
Double the wonderful question ! I have good food
Wrote a hand O ( n 4 ) O(n^4) O(n4) Search for ,T 了 .
And then think dp .
Simple approach , set up dp[k][i][j] Express i To j after <= k The longest path of an edge .
If dp[k][i][i] > 0 Then it is proved that there is a ring . Time complexity or O ( n 4 ) O(n^4) O(n4) .
Obviously multiplier optimization . set up dp[k][i][j] Express i To j after <= 2^k The longest path of an edge .
And then a brain puff , Abandon this practice .
From high to low . If there is no ring , Just put 2^i Spell it in .
The answer is ans+1 .
expand : The minimum ring problem ( Edge weight and the smallest ring ). tips:floyd Algorithm , Time complexity O(n^3) . The same is the problem of rings , All borrowed the idea of multi-source shortest path , But the solution is slightly different .
Boboniu and String
This sewing problem almost scared me
thank Rabbit_Mua With the help of the
It has nothing to do with strings .
Consider abstracting into a pair of points in the coordinate system (a,b) .
Suppose the selected string t Coordinate for (x,y) .
Yes 6 You can move in two directions . Almost scared again
Two points answer . Control every point to fall into this area .
Now the problem is almost transformed . The next thing to do is to find (x,y) The value range of .
First of all, it must be in a rectangular area .
Secondly, it must be between two slashes .
Finally get x ∈ [ L , R ] , y ∈ [ L 2 , R 2 ] , y − x ∈ [ L 3 , R 3 ] x\in [L,R], y\in [L2,R2], y-x\in [L3,R3] x∈[L,R],y∈[L2,R2],y−x∈[L3,R3] .
Judge [ L 2 − R , R 2 − L ] ∩ [ L 3 , R 3 ] [L2-R,R2-L]\cap[L3,R3] [L2−R,R2−L]∩[L3,R3] that will do .
tips:
- The combination of number and form , Abstract and transform the original problem .
- Using inequality to limit the solution of the problem
The Hidden Pair
thank xpx And help with problem solving
Interactive questions have a lot to consider , So solving interactive problems is not a simple thing
First of all, we put n Ask one point , The point thus obtained must be on the path of the two marked points .
Suppose we know one of the marking points , Then another marking point can be used 1 Ask again to find , Just ask all the points with the same depth as the other marked point after removing the path from this marked point to the root ( The depth of the other mark point can be subtracted from the distance between the two mark points calculated before )
in fact , We only need to know the depth of one of the marked points to find this point .
It is assumed that the required marking point depth is [l,r] Between
We can find in two .
Suppose the depth is [mid,r] Ask all the questions , If the returned length = The distance between two marked points , Prove the depth of one of the marked points >=mid .
Maybe we should pay attention to the writing of dichotomy .
So the total number of inquiries 1 + ⌊ log 1000 ⌋ + 1 = 12 1+\lfloor\log1000\rfloor+1=12 1+⌊log1000⌋+1=12 .
How to optimize ?
Notice that our original dichotomy range is [0,D] (D Represents the depth of the tree )
In fact, we only need to find the deeper mark point .
So the real dichotomy range is [(len+1)/2,min(D,len)]
In this way, the number of inquiries will be exactly one less .
tips:
- Beginning with interactive questions , To understand its format and problem-solving ideas
- As far as the subject is concerned , The property of the shortest path is used , The nature of the distance between two points on a tree , And two points . In general, we can only think through the problem , To solve an interactive problem .
边栏推荐
- Vnctf 2022 cm CM1 re reproduction
- Oracle-数据完整性
- fluttertoast
- Problem solving: how to manage thread_local pointer variables
- The question of IBL precomputation is finally solved
- 【学习笔记】构造
- C language file operation for conquering C language
- DLS-20型双位置继电器 220VDC
- Multi graph explanation of resource preemption in yarn capacity scheduling
- Sword finger offer 19 Regular Expression Matching
猜你喜欢
剑指 Offer 18. 删除链表的节点
High quality pump SolidWorks model material recommended, not to be missed
蒹葭苍苍,白露为霜。
C # generates PPK files in putty format (supports passphrase)
Left join displays the specified value when the left join matching data is null
DX-11Q信号继电器
[original] PLSQL index sorting optimization
解析融合学科本质的创客教育路径
双位置继电器ST2-2L/AC220V
Hoo research | coinwave production - nym: building the next generation privacy infrastructure
随机推荐
Metauniverse and virtual reality (II)
最长的可整合子数组的长度
The communication mechanism and extension of Supervisor
PyTorch安装并使用gpu加速
奇偶链表[链表操作的两种大方向]
Multi graph explanation of resource preemption in yarn capacity scheduling
XJY-220/43AC220V静态信号继电器
Set different background colors for the border and text of the button
Exercises on recursion in C language
蒹葭苍苍,白露为霜。
对libco的一点看法
Sword finger offer 18 Delete the node of the linked list
文件服务设计
What is product thinking
实验八 T-sql,存储过程
pytorch编程知识(2)
leetcode 474. Ones and Zeroes 一和零(中等)
The quantity and quality of the devil's cold rice 101; Employee management; College entrance examination voluntary filling; Game architecture design
关于VCTK数据集
C language file operation for conquering C language