当前位置:网站首页>[learning notes] shortest path + spanning tree
[learning notes] shortest path + spanning tree
2022-06-28 08:14:00 【Ants looking up at the stars】
Difficult subject
Opening Portals
Good question !
We call the portal the key point .
Let the distance between any two keys be dist(i,j) , Considering the nature of the transmission , All you need is a spanning tree that connects all the key points , And then traverse from any key point , Exactly the sum of the edge weights of the spanning tree .( It's a little twisted )
If we start at each key point dijkstra , The time complexity is O ( n 2 log n ) O(n^2\log n) O(n2logn) .
For this model , We have a Multi source shortest path Algorithm :
- Start with each key , Find the shortest distance to each point
- Consider enumerating an edge (u,v,w) , Connect the two keys closest to the two endpoints of this edge :( It is equivalent to enumerating transit points )

The correctness is obvious .
Specially ,MST That is, every point is a key point .
Of course , An edge may be computed multiple times on the spanning tree .

Complete the MST
This problem does not require a sophisticated algorithm . Direct recklessness
You can run the complete graph directly MST , Then find a small spanning tree ( Just discuss it separately ) .
Jumping Around
boruvka Board questions
Trial for Chief
What a delicate little structure !
I never thought it was the shortest circuit !
Consider from (i,j) set out , The distance between adjacent grids with different colors is 1 , The distance between grids with the same color is 0 , Find the farthest black grid , The answer for dist+1 .( Special judgment: all white )
Consider its meaning . Equivalent to alternating black and white , Operate greedily .
Flights
Cuckoo ...
Difference constraint + shortest path !!

Capitalism
Wonderful topic !
First, it is judged that the odd ring must have no solution .
The picture of this problem is very special , Because it's a two-way side , Therefore, starting from any point of the connected block, you can reach other points . So let's enumerate S As a starting point , Run differential constraint .

What happens is that there will be no edge connected dis[u]=dis[v] The situation of , Otherwise, odd rings will appear .
In this way, we can get the solution of a combination method .
Then, the maximum range must be satisfied .
Cannot build super origin .qwq
边栏推荐
- Generation and verification of JWT token
- Airflow2.x distributed deployment DAG execution failure log cannot be obtained normally
- [shangpinhui] project notes
- Doris学习笔记之介绍、编译安装与部署
- Unity - Pico开发 输入系统等相关API的使用---C#篇
- MySQL row format parsing
- Soft exam -- software designer -- afternoon question data flow diagram DFD
- Reverse mapping of anonymous pages
- asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
- Unity 获取当前物体正前方,一定角度、距离的坐标点
猜你喜欢

PLSQL installation under Windows

Devops foundation chapter Jenkins deployment (II)

Introduction to kubernetes (I)

Soft test -- software designer -- database design of afternoon questions

Do you know TCP protocol (1)?

Children's unit of 2022 Paris fashion week ended successfully at Wuhan station on June 19

新唐NUC980使用记录:自制开发板(基于NUC980DK61YC)

SOC timer and interrupt configuration

【学习笔记】最短路 +生成树

Discussion on the application of GIS 3D system in mining industry
随机推荐
Airflow2.1.1 summary of the pits stepped on in actual combat!!
Connaissez - vous le protocole TCP (2)?
asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
2022巴黎时装周儿童单元6.19武汉站圆满落幕
Three step problem of leetcode
SOC timer and interrupt configuration
asp. Net registration page
22/02/14 study notes
Redis persistence problem and final solution
About ASM disk space full, clean up ASM disk
Study notes 22/1/19 and 22/1/20
The maximum number of Rac open file descriptors, and the processing of hard check failure
Unity - Pico开发 输入系统等相关API的使用---C#篇
小艺人黄鑫洋受邀参加巴黎时装周儿童单元武汉站
AI首席架构师8-AICA-高翔 《深入理解和实践飞桨2.0》
PC端隐藏滚动条
Buffer pool in MySQL
About RAC modifying scan IP
js取整的小技巧
Study notes 22/1/17