当前位置:网站首页>【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
边栏推荐
- Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
- 包 类 包的作用域
- Error statuslogger log4j2 could not find a logging implementation
- JMeter -- distributed pressure measurement
- Minor spanning tree
- [crampon game] MC tutorial - first day of survival
- Serpentine matrix
- Power management bus (pmbus)
- English topic assignment (27)
- windows下Redis-cluster集群搭建
猜你喜欢

MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP

File upload bypass summary (upload labs 21 customs clearance tutorial attached)

直播預告 | 容器服務 ACK 彈性預測最佳實踐

Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...

SPI read / write flash principle + complete code

Label exchange experiment

Introduce Hamming distance and calculation examples

Uncover the seven quirky brain circuits necessary for technology leaders

Download the details and sequence of the original data access from the ENA database in EBI

The principle of attention mechanism and its application in seq2seq (bahadanau attention)
随机推荐
Pointer function (basic)
直播预告 | 容器服务 ACK 弹性预测最佳实践
How can CIOs use business analysis to build business value?
机器学习 --- 神经网络
level18
[crampon programming] lintcode decoding Encyclopedia - 1100 strange printer
Introduction to RT thread kernel (4) -- clock management
Sequence diagram of single sign on Certification Center
Here comes the Lantern Festival red envelope!
2022-2028 global and Chinese FPGA prototype system Market Research Report
jmeter -- 分布式压测
[uniapp] system hot update implementation ideas
A survey of automatic speech recognition (ASR) research
Mode in BST (binary tree & Notes on question brushing)
Basic analysis of IIC SPI protocol
Machine learning decision tree
Qt蓝牙:搜索蓝牙设备的类——QBluetoothDeviceDiscoveryAgent
10 programming habits that web developers should develop
Chapter 6 text processing tools for shell programming (awk)
程序员应该怎么学数学