当前位置:网站首页>【acwing】528. cheese
【acwing】528. cheese
2022-07-05 04:41:00 【The wind is a little strong】
subject
Ideas
Train of thought
One sentence question : You have to go from the lowest point to the highest point , You must start from the hole connecting with the lower boundary , And you can only walk to the cheese connected with your cheese every time .
For two cheeses , Their distance must be less than 2×r, Is considered to be interlinked .
Two points in space P1(x1,y1,z1)、P2(x2,y2,z2) The formula of distance is as follows :
Conditions
The condition of this topic is : Connectivity & Distance formula between two points .
The nature of this topic : Or the connectivity mentioned above . That is, the two cheeses must be connected , Can be transferred
Algorithm to choose : Let's have a preliminary look at this topic , Find it particularly cumbersome , However, in fact, this problem is a maze problem in plane rectangular coordinate system .
For the maze problem , obviously BFS Breadth first search is our best choice .
Analytic algorithm
First of all, for a search topic , We still have three basic goals
Goal one : Direction indicator array : For this topic , Obviously, every hole connected with it can , So the direction of this question indicates that the array is useless .
Goal two : Boundary treatment : For this topic , In fact, there are no requirements for our coordinates , Because connectivity already contains all the conditions .
Goal three : Expand the guidelines : Every search topic , The difficulty often lies in this expansion criterion , This topic is no exception , We found that , The expansion criterion of this topic is the connectivity in the topic , As long as the two points are connected , Then we can expand .
Train of thought two
Obvious , This problem is related to joint search
Let's look at the picture above , Do you see some doorways ? We divide all holes into several sets , Once two cavities intersect or tangent , Just put them in the same set .
We can also draw 2 Special elements , Represent bottom and top respectively , If a cavity contacts the bottom , Then put it in the same set as the element representing the bottom , The same is true for the top . Last , Just see if the top and bottom are in the same set . This can be achieved by merging and searching sets .
Idea 1 code
Thought two code
边栏推荐
- 这是一个不确定的时代
- Official announcement! The third cloud native programming challenge is officially launched!
- Wan broadband access technology V EPON Technology
- Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
- Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
- Sword finger offer 07 Rebuild binary tree
- Neural networks and deep learning Chapter 5: convolutional neural networks reading questions
- 机器学习 --- 神经网络
- TPG x AIDU|AI领军人才招募计划进行中!
- Stage experience
猜你喜欢
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
A solution to the problem that variables cannot change dynamically when debugging in keil5
概率论与数理统计考试重点复习路线
[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
Fonction (sujette aux erreurs)
防护电路中的元器件
Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices
可观测|时序数据降采样在Prometheus实践复盘
The principle of attention mechanism and its application in seq2seq (bahadanau attention)
随机推荐
[finebi] the process of making custom maps using finebi
线上故障突突突?如何紧急诊断、排查与恢复
[uniapp] system hot update implementation ideas
[Business Research Report] top ten trends of science and technology and it in 2022 - with download link
Hexadecimal to decimal
Neural networks and deep learning Chapter 4: feedforward neural networks reading questions
Leetcode 222 number of nodes of complete binary tree
A solution to the problem that variables cannot change dynamically when debugging in keil5
官宣!第三届云原生编程挑战赛正式启动!
Key review route of probability theory and mathematical statistics examination
Managed service network: application architecture evolution in the cloud native Era
PHP读取ini文件并修改内容写入
Setting up redis cluster cluster under Windows
直播預告 | 容器服務 ACK 彈性預測最佳實踐
揭秘技术 Leader 必备的七大清奇脑回路
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
Power management bus (pmbus)
函数(易错)
Uncover the seven quirky brain circuits necessary for technology leaders
flutter 对象和列表