当前位置:网站首页>[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
边栏推荐
- 城联优品向英德捐赠抗洪救灾爱心物资
- ROS notes (08) - definition and use of service data
- asp. Net to search products and realize paging function
- ROS 笔记(08)— 服务数据的定义与使用
- Is it reliable for securities companies to register and open accounts? Is it safe?
- Is it reliable to open an account by digging money? Is it safe?
- 图像翻译/Transformer:ITTR: Unpaired Image-to-Image Translation with Transformers用Transfor进行非配对图像对图像的转换
- 【学习笔记】拟阵
- SLAM中常用的雅克比矩阵J
- 小艺人黄鑫洋受邀参加巴黎时装周儿童单元武汉站
猜你喜欢

NLP sequence can completely simulate human brain intelligence

你了解TCP协议吗(一)?

Ambari (V) ---ambari integrated Azkaban (valid for personal test)

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

MySQL row format parsing

ROS 笔记(09)— 参数的查询和设置

Unity 获取当前物体正前方,一定角度、距离的坐标点

Airflow2.x distributed deployment DAG execution failure log cannot be obtained normally

After installing NRM, the internal/validators js:124 throw new ERR_ INVALID_ ARG_ TYPE(name, ‘string‘, value)

The solution of "user account control to continue, please enter administrator user name and password" appears in win10 Professional Edition
随机推荐
Ambari (V) ---ambari integrated Azkaban (valid for personal test)
解决npm ERR! Unexpected end of JSON input while parsing near问题
关于如何在placeholder中使用字体图标
B_ QuRT_ User_ Guide(30)
Reverse mapping of anonymous pages
Vagrant installation
Usage record of Xintang nuc980: self made development board (based on nuc980dk61yc)
Airflow2 configuration windows azure SSO details based on oauth2 protocol
js运算符的优先级
你了解TCP协议吗(二)?
Leetcode swing series
安装nrm后,使用nrm命令报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)
Eslint 语法监测关闭
Doris学习笔记之介绍、编译安装与部署
GPIO configuration of SOC
Unity - Pico开发 输入系统等相关API的使用---C#篇
npm清理缓存
Oracle view tablespace usage
【学习笔记】差分约束
How to insert a single quotation mark into a table as a data type in Oracle pl/sql