当前位置:网站首页>【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
边栏推荐
- [popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
- 49 pictures and 26 questions explain in detail what is WiFi?
- Uncover the seven quirky brain circuits necessary for technology leaders
- A survey of automatic speech recognition (ASR) research
- Pointer function (basic)
- How to carry out "small step reconstruction"?
- Neural networks and deep learning Chapter 2: machine learning overview reading questions
- Practice | mobile end practice
- CSDN正文自动生成目录
- 这是一个不确定的时代
猜你喜欢
MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP
Label exchange experiment
Solution of circular dependency
[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens
level17
Introduce Hamming distance and calculation examples
自动语音识别(ASR)研究综述
Network layer - forwarding (IP, ARP, DCHP, ICMP, network layer addressing, network address translation)
About the prompt loading after appscan is opened: guilogic, it keeps loading and gets stuck. My personal solution. (it may be the first solution available in the whole network at present)
49 pictures and 26 questions explain in detail what is WiFi?
随机推荐
Serpentine matrix
Inline built-in function
取余操作是一个哈希函数
假设检验——《概率论与数理统计》第八章学习笔记
Basic analysis of IIC SPI protocol
A solution to the problem that variables cannot change dynamically when debugging in keil5
English topic assignment (26)
Sword finger offer 04 Search in two-dimensional array
首席信息官如何利用业务分析构建业务价值?
Leetcode hot topic Hot 100 day 33: "subset"
Interface joint commissioning test script optimization V5.0 (end)
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
Here comes the Lantern Festival red envelope!
Debug insights
All in one 1413: determine base
Data security -- 14 -- Analysis of privacy protection governance
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
Key review route of probability theory and mathematical statistics examination