当前位置:网站首页>[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 .
边栏推荐
- Service
- 对libco的一点看法
- 冲击继电器ZC-23/DC220V
- DLS-20型双位置继电器 220VDC
- [daily record] - bug encountered in BigDecimal division operation
- What is the difference between Pipeline and Release Pipeline in azure devops?
- DLS-42/6-4 DC110V双位置继电器
- Pytorch installs and uses GPU acceleration
- Analysis of blocktoken principle
- P4学习——p4runtime
猜你喜欢
随机推荐
P4 learning - Basic tunneling
Tibetan poem PTA
Oracle data integrity
Unhandled Exception: MissingPluginException(No implementation found for method launch on channel)
连表查询 select 生成
Win11安装redis 数据库以及redis desktop manager的下载
2022就要过去一半了,挣钱好难
关于Unity一般的输入操作方式
Exercises on recursion in C language
Tcp/ip protocol stack, about TCP_ RST | TCP_ ACK correct attitude
K210门禁毕设
Left join displays the specified value when the left join matching data is null
The longest selling mobile phone in China has been selling well since its launch, crushing iphone12
NE555 waveform generator handle tutorial NE555 internal structure (I)
技术人进阶画业务大图,手把手教学来了
How to do the performance pressure test of "Health Code"
CMU15445 (Fall 2019) 之 Project#1 - Buffer Pool 详解
孔乙己第一问之服务通信知多少?
Two-stage RO: part 1
ORB-SLAM2源码学习(二)地图初始化

![奇偶链表[链表操作的两种大方向]](/img/4e/ce860bc172bb75f456427ba26a7842.png)







