当前位置:网站首页>F-niu Mei's apple tree (diameter combined)
F-niu Mei's apple tree (diameter combined)
2022-04-23 09:42:00 【Zimba_】
The question :
A tree n n n A tree of nodes , Each edge has an edge weight w i wi wi. Yes q q q Time to ask , Every time I ask l l l and r r r, seek m a x ( d i s t ( u , v ) ) , l ≤ u ≤ v ≤ r max(dist(u,v)),l\leq u\leq v\leq r max(dist(u,v)),l≤u≤v≤r.
( 1 ≤ n , q ≤ 300000 ) (1\leq n,q\leq 300000) (1≤n,q≤300000)
practice :
Here's a conclusion : The diameter endpoints of two subgraphs are known , Then the diameter of the merged two graphs , Take the farthest two of these four points .
So this problem is considered to be multiplied to deal with ST surface . You need to merge the maximum values of the two intervals , Just save the diameter endpoint of each interval , You can merge to get a new diameter .
Code :
The solution is so simple , Code YY Just a moment .
版权声明
本文为[Zimba_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230621425179.html
边栏推荐
- Go language learning notes - structure | go language from scratch
- Flutter 的加载动画这么玩更有趣
- Introduction to sap pi / PO login and basic functions
- (Extended) bsgs and higher order congruence equation
- Three challenges that a successful Devops leader should be aware of
- MySQL of database -- overview and installation
- JS what is an event? Event three elements and operation elements
- JS and how to judge custom attributes in H5
- Kernel PWN learning (4) -- double fetch & 0ctf2018 baby
- Give the method of instantiating the object to the new object
猜你喜欢
Simple understanding of arguments in JS
Leetcode question bank 78 Subset (recursive C implementation)
Kettle实验 (三)
Machine learning (VI) -- Bayesian classifier
Dropout技术之随机神经元与随机深度
Go language learning notes - slice, map | go language from scratch
Leetcode0587. 安装栅栏(difficult)
Kettle实验 (三)
Principle of synchronized implementation
MySQL of database -- Fundamentals
随机推荐
如何实现根据照片获取地理位置及如何防御照片泄漏地理位置
Personal homepage software fenrus
三、6【Verilog HDL】基础知识之门级建模
Golang force buckle leetcode 396 Rotation function
Explanation of order and primitive root of number theory
Pre parsing of JS
Kettle experiment (III)
Principle of synchronized implementation
How to obtain geographical location based on photos and how to prevent photos from leaking geographical location
Kettle experiment
Number of islands
C语言:表达式求值(整型提升、算术转换 ...)
Two declaration methods of functions of JS
Operation not allowed for a result set of type resultset TYPE_ FORWARD_ ONLY. Explain in detail
Go language learning notes - exception handling | go language from scratch
kettle实验
SAP debug debug for in, reduce and other complex statements
Example of data object mask used by SAP translate
ABAP CDs view with association example
JS case to find the maximum value, reverse the array, bubble sort