当前位置:网站首页>【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
边栏推荐
- How to force activerecord to reload a class- How do I force ActiveRecord to reload a class?
- 官宣!第三届云原生编程挑战赛正式启动!
- Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
- Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
- Raki's notes on reading paper: code and named entity recognition in stackoverflow
- [uniapp] system hot update implementation ideas
- Wenet: E2E speech recognition tool for industrial implementation
- TPG x AIDU | AI leading talent recruitment plan in progress!
- American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
- Hexadecimal to decimal
猜你喜欢
Official announcement! The third cloud native programming challenge is officially launched!
[Business Research Report] top ten trends of science and technology and it in 2022 - with download link
WeNet:面向工业落地的E2E语音识别工具
The 22nd Spring Festival Gala, an immersive stage for the yuan universe to shine into reality
Solution of circular dependency
【科普】热设计基础知识:5G光器件之散热分析
[thingsboard] how to replace the homepage logo
windows下Redis-cluster集群搭建
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
取余操作是一个哈希函数
随机推荐
[popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
计组笔记(1)——校验码、原补码乘除计算、浮点数计算
PR video clip (project packaging)
Wan broadband access technology V EPON Technology
Chapter 6 text processing tools for shell programming (awk)
JVM 原理和流程简介
解密函数计算异步任务能力之「任务的状态及生命周期管理」
Burpsuite grabs app packets
Hexadecimal to octal
2022-2028 global and Chinese equipment as a Service Market Research Report
After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
Introduce Hamming distance and calculation examples
程序员应该怎么学数学
函數(易錯)
What are the building energy-saving software
Here comes the Lantern Festival red envelope!
A survey of automatic speech recognition (ASR) research
Aperçu en direct | Services de conteneurs ACK flexible Prediction Best Practices
Live broadcast preview | container service ack elasticity prediction best practice
Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation