http://acm.hdu.edu.cn/showproblem.php?pid=1010Tortured me all afternoonThe main topic: from S point to D Point can just walk K step at the beginning thought is wide search, actually is deep search.DFS multi-optimization before it's over.#include #include#include#include#includestring.h>#include#include#includeusing namespacestd;#defineN 10#defineMemset (A, B) memset (A,b,sizeof (a))#defineLson r#defineRson rstructnode{intX,y,step;} S,e;intn,m,k;intdis[4][2]={{1,0},{-1,0},{0,1},{0,-1}};intVis[n][
Topic Links:This topic is very good, has difficulty, can do well to do more;#include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. poj-1190-Birthday cake-dfs (Deep Search)-enumeration-Multiple pruning
Topic Link: PortalTest instructionsDivides a sequence of length n into identical sub-sequences and cannot have a cross.Analysis:For a number we first put it in the va[] array, if the next number to be discussed is the same as the first number in VAThen this number is probably the first number of the second sequence.Then there are several situations:1) This number is a number in the middle of the V1, directly into the V1.2) The first number of the V1 is placed in the V2, code is as follows: #i
, M, K (0 The second line contains K integers ci (ci > 0), 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 col
solution, first in the first column a place to place a queen, Mark line number Row[i] (Row[i] can not put the Queen, or conflict), and then in the second column to find possible legal position, BLABLABLA, until the N queen all put, recursion end. There may be doubts when judging the feasibility. The judgment is sure to be OK, in judging the slash, we use the slope is not equal to the positive and negative judgment, and this two points in the chessboard coordinates, just can use (Posted_num,row[
#include Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. HDU 1010 Heuristic search + odd-even pruning
problem Description:The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone is a trap, and he tried desperately to get out of this maze.The maze is a rectangle with sizes N by M. There is a door in the maze. At the beginning, the door is closed and it would open at the t-th second for a short period of time (less than 1 second) . Therefore the doggie had
Sticks
Time Limit: 1000MS
Memory Limit: 10000K
Total Submissions: 122771
Accepted: 28441
DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most units long. Now he wants to return sticks to the original state, but he forgot what many sticks he had originally and how long they wer E originally. Him and design a program which computes the smallest possible original length of those sticks.
Click to open Hangzhou electric 1518Problem Descriptiongiven a set of sticks of various lengths, is it possible to join them end-to-end to form a square?Inputthe first line of input contains N, the number of test cases. Each test case is begins with an integer 4 Outputfor each case, the output a line containing "yes" if was is the possible to form a square; Otherwise output "no".Sample Input34 1 1 1 15 10 20 30 40 508 1 7 2 6 4 4 3 5Sample OutputYesnoyesTest instructions: Judging whether the giv
The meaning of the question is clear. There are six search methods: top, bottom, left, right, front, and back.
Only this question requires pruning.
N [A-1] [B-1] [C-1] = 1 or a + B + C-3> T when the direct output-1 can be. Save about Ms
Question:
From 0, 0 to the A-1, B-1, C-1.6 walk.
Analysis:
Minimum steps, BFs.
This eliminates the need to prioritize queues and saves some time.
Code:
# Include
I am so depressed that I will use the DP Method for a common search question, and the results will always be done by TLE and Wa. If the sum of all numbers is an odd number, there is certainly no positive solution.
14133454
10317
Equating Equations
Accepted
C ++
0.102
2014-09-02 09:01:23
# Include [Ultraviolet A] 10317-equating equations (DFS + pruning)
number of nodes N (2 Output file must contain a single integer-the maximum traffic between the subnetworks.OutputOutput must contain a single integer-the maximum traffic between the subnetworks.Sample Input30 50 3050 0 4030 40 0Sample Output90Test instructions: Divides the number of n into two sets, which is the largest of all the numbers in one set to the other.1#include 2#include 3#include string.h>4#include 5#include 6 7 using namespacestd;8 Const intMAX = A;9 intA[max][max],v[max],b[max];Te
Hdu 1689 Alien's neck.pdf (bfs layered graph pruning)
Alien's neck.pdf
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission (s): 1526 Accepted Submission (s): 415
Problem DescriptionJYY is taking a trip to Mars. to get accepted by the Martians, he decided to make a magic neck.pdf for their king. (Otherwise, JYY will be eaten) Now, he has collected using magic bils, and he is going to string them up.
Unfort
UVA10317-Equating Equations (backtracking + pruning)
Question Link
Question: Give a formula, but this formula is not necessarily an equation. In the case of '+', '-', '=', the positions of digits remain unchanged, make it an equation and, if possible, output an arrangement.
Idea: we move all the numbers on the right of the equal sign to the right of the equal sign, for example, a + B-c = d-e. After moving it to a + B + e-(c + d) = 0, that is, a + B
True pruning can improve a lot of efficiency, although there are more steps that can be calculated when cutting. But that's just an increase in multiples. In exchange for the decline in the index.
There is also the need to pay attention to boundary conditions.
#include
1670
This problem is similar to poj2362 and requires more pruning. The main idea is that there are many long sticks, chopped up, and now requires the smallest possible length of the original stick.
The stick is still sorted from large to small, reducing the number of recursion.
Because all the sticks have to be used, so the length of the stick must >= the longest stick. Find out the total length of the stick sum, and then start with the longest stick lengt
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.