Summary: we can search down at the same depth when the initial state is about to reach the termination state, which covers a wider range and is very useful when the depth of the solution is small.
Tips and notes:
BFS has many tips. Let me list them one by one:
Note:: When saving BFS status, you must try to reduce the status and store only valid information for BFs, instead of storing the entire figure (Qaq and noip are suspended in this way. It was too weak at the time ..)
Hash weight: In some BFS questions, where the range of all elements is small (you can also map them yourself), let's assume that there are K yuan, we can consider using hash based on the power of the base number in K-base, for example, [wikioi] 1004 sizgame, [bzoj] 1054: [haoi2008] mobile toys (BFS + hash ),
Array Weighting: In some cases, such as pure BFS or direction restrictions, you can open multi-dimensional arrays to record the access status. For example: [wikioi] Ralf, who escaped in 1026 (heavy direction), [bzoj] 1616: [usac2008 Mar] cow, travelling, wandering dairy cows (DP/-BFS) (strong decision), [bzoj] 1644: [usac2007 Oct] obstacle course obstacle Training Course (BFS) (heavy direction Judgment ),
Obstacle distance: When you see a picture of the maximum number of obstacles from the start point to the end point to give you BFs, you can think against it. We think the minimum number of obstacles to be crossed from this point to the end point, then, use K to determine whether it is legal, for example:
Multiple Constraints: When the number of constraints increases, we can consider maintaining multiple types of information when BFS is transferred, and then making decisions based on the question, for example: [bzoj] 1632: [usaco2007 Feb] Lilypad pond (BFS)
Circle Constraint: When BFS asks us to take the shortest distance around a specified shape (with a connected shape), we can take a Ray from the point of the Shape boundary, then, the BFS is maintained after the BFS, that is, it does not pass through the ray, or it does not pass through the ray to the need to pass through the ray. That is to say, we need to maintain the latter when we make a round trip, for example, [bzoj] 1656: [usaco 2006 Jan] The Grove tree (BFS + Special tips)
Bidirectional search: When you encounter a minimum number of moving steps from the initial status to the target status, we can perform BFS in both the initial and target statuses, then you can determine whether the intersection exists. I wrote a question a long time ago. I don't know which question ..
Summary: BFS