Link: tempter of the bone
For the first time, I had to cut the topic and cut it out. To tell the truth, the research was not too short. It seemed that there was no substantial progress. When I encountered a problem, I absolutely had no way to start. pruning became increasingly mysterious ....
Hdu1010 is a classic topic for pruning. I tried to use BFS and submitted wa for more than 10 times. Then I checked
Because the depth is certain (M), we use depth-first search to set the cake serial number from top to bottom. The top layer is layer 1st ,......, The bottom layer of the cake is the m layer. It is obvious that the front I layer meets the question conditions (from the top layer (that is, the layer numbered 1) starts counting) mins [I] And MINV [I] are obtained when the radius and height of the layer are both I, therefore, pruning is required. The
;maxturncount) * return false; $ Panax Notoginseng //the location of the road is not the same row as the end point, then at least one more turn, but the current number of turns is equal to the maximum number of turns the road fetish can withstand - if(Row! = destination.x col! = destination.y Turn[row][col] = =maxturncount) the return false; + A for(inti =0; I 4; ++i) the { + intR = row + dir[i][0]; - intC = col + dir[i][1]; $ if(true=
http://acm.hdu.edu.cn/showproblem.php?pid=1010Test instructions: Just give a maze, the puppy must go through the specified number of steps to reach the exit, and each lattice can only walk once.First of all, let's introduce the odd-and-even pruning:In this topic, if you use pruning, you can save a lot of time.In this topic, each time the DFS cycle can be judged by the puppy's current position and the end of the number of steps, if not an even, the des
Test instructionsEnter a maze of N * M, the maze where ' S ' represents the location of the puppy, ' X ' stands for traps, ' D ' stands for the door, '. ' Represents a place to walk, a puppy can choose to walk around in four directions at a time, and ask if the puppy can find the door just by T-step.Ideas:This problem pruning is especially important with backtracking + pruning.Pruning One:You can think of a diagram like this:1 0 1) 0 10 1 0) 1 01 0 1)
Test instructions: A puppy should be at the end of the T-moment from the beginning to the finish line, ask can.Pay attention to pruning.1#include 2#include 3#include 4 using namespacestd;5 intmaze[9][9];6 BOOLvis[9][9];7 intn,m,t;8 BOOLans;9 struct PointTen { One intx, y; A }; - intdx[4]={0,0,-1,1}; - intdy[4]={1,-1,0,0}; the Point p,e; - voidDFS (Point cur,intDEP) - { -vis[cur.x][cur.y]=true; + if(!anscur.x==e.xcur.y==e.ydep==t) - { +ans=
Title: EOJ1981 | | POJ1011 Classic dfs+ pruning + bizarre DataDescriptionGeorge took sticks of the same length and cut them randomly until all partsbecame at most units long. Now he wants to return sticks to the originalstate, but he forgot how many sticks he had originallyInputThe input contains blocks of 2 lines. The first line contains the number ofsticks parts after cutting, there is at most sticks. The second linecontains the lengths of those par
The main idea: to be a r*c button matrix from all to turn all the time to open the minimum number of times, each press switch can affect the range of variable.Topic Analysis: Switch problem. Drill A look is bfs+ bit compression, but write out after the tle. Constantly update the optimal solution with DFS. In case of 2^25, add two pruning:First, each switch can only affect three lines, when the now_r-2 line still has a switch off, then this scheme can not be all the buttons open, cut off (and is
Powerful image capture pruning artifact: A brief analysis of Android Simplecropview and its instance code reuseSimplecropview is the first third-party open source image pruning tool on GitHub, powerful and well designed. I personally think that Simplecropview is more powerful and complete than the Cropper described in Appendix 1, but also more complex, if it is a simple application scenario, then Cropper is
Python uses higher-order functions to achieve pruning, and python Higher-Order Functions
This article shares with you the specific code of using a higher-order function to implement a pruning function for your reference. The specific content is as follows:
Case:
In some cases, we want to add multiple functions, such as timing statistics, logging, and caching operation results.
Requirements:
You do not need
Test instructions: Tell the grid specifications, the number of colors, and each color can be applied to the number of squares, asked whether it can achieve the number of adjacent two different colors of the grid.Analysis: Because the data is small, the lattice is up to 5 * 5 size, so DFS can be used. Once the tle has started pruning, 31ms is over. Pruning to see the code.1#include 2#include 3#include 4#incl
Links: http://vjudge.net/problem/23314Analysis: Two kinds of pruning schemes.1. Find out the number of points that can be reached at the current location (although the number of points actually can be reached is smaller than it, but optimistic estimates can be), if the current number plus the number is still less than the current optimal solution length, then pruning.2. If the number can be reached from sma
number, storing the corresponding position subscript, which is convenient for calculating the position.
pruning : subtracting unnecessary calculations (although not necessary for the subject)
use of library functions : The use of memcpy,strchr,strlen,next_permutation simplifies the code and highlights the logical part.
The code is implemented as follows:1#include 2#include 3#include 4#include 5 using namespacestd;6 7 Const intmaxn=Ten, i
Reprinted please indicate the source, thank youHttp://blog.csdn.net/acm_cxlove/article/details/7854526By --- cxlove
Question: Give a matrix of N * n. Find an empty grid and place the two in turn into 0 and 1. Finally, we can see that there are more than 0 connections or more than 1 connections. (My statement is purely nonsense)
Http://poj.org/problem? Id = 3317
The question is whether the current person has an optimal strategy.
It is still a very small search, extracted from the empty la
Question: Use a case to explain 4 4 5 S.x. . X. .. XD .... In this case, it is a 4*4 map ,. it indicates a place to go, X indicates a place not to go, s indicates the starting point, and D indicates the target point. After a point is not reached, this point cannot go. If the start time is 0, you can see if the start time can be d when the start time is 5. Obviously, this case cannot Question: Here I learned a pruning: path
), denoting the number of cells where the i-th color should is used.It ' s guaranteed that C1 + C2 + + CK = Nxm.Outputfor Each test case, the first line contains ' case #x: ', where x is the case number (starting from 1).In the second line, output "No" if there is no coloring satisfying the requirements. Otherwise, Output "YES" in the one line. Each of the following N lines contains M numbers seperated by single whitespace, denoting the color of the cells.If There is multiple solutions, output a
DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long they were originally. please help him and design a program which computes the smallest possible original length of those sticks. all lengths expressed in units are integers greater than zero.
InputThe input contains blocks of 2 lines. the first line contains the number
Question:
When you find a path to the end point, it is exactly the same as the given time. Every time you move a unit, it will increase by one minute and you cannot go back.
After a DFS search, set visit [x] [Y] to 1, indicating that the access is successful. Remember to change visit to 0 again during backtracking;
This question is very easy, so we need to focus on pruning and list all the conditions that can exit DFS recursion.
Set a flag. When the
Question Portal
It is obviously a search. However, there is no pruning at the beginning, and the brute force search starts from,NaturallyT has 6 points.
#include
Consider pruning. From the perspective of human intelligenceAlthough I have never playedWe must start from a region with more options, because fewer decisions are available for us. So here we can also use this idea for reference. Every time we make
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.