UV 10318-Security Panel dfs pruning
ACM
Address: Ultraviolet A 10318-Security Panel
Question:This is similar to the lighting question. When a lamp is selected, the lighting game changes its status and the surrounding lights.However, we have a special on-and-off technique, which provides a location for changing the status, rather than changing around the clock.Ask the minimum switch step from shutting down all to turning on all.
Analysis:Obviously, it
// At the beginning, I used BFS for continuous wa, BFS is used to find the shortest path, and this question is to find the fixed time // paper-cut parity pruning and DFS # include
Good DFS + parity Pruning for zoj 2110
There are n people, and K people can choose to be the mother of the disease, and the uninfected people who are in direct contact with the patient will be infected, find out which of the K people can obtain the most number of patients, there are the same ones with small numbers.
Simple search: pruning means that if the same mother can be directly or indirectly transmitted by other mothers, this mother will certainly not be the most, but will only be a
DFS + pruning * 4 (barely passed ):1. Only half of the game is enumerated, and the other half is obtained directly. 2. process the prefix and. If the value is greater than the target score, the system prunes the value. 3. The prefix and the value are added. If the score for the next victory is still less than the target score, the system prunes the value. 4. When enumerating each person's last game, use the target score-prefix and calculate the expect
This problem did not find a circuit, so can not be used with 11,521 array storage after output. I used the method is DFS plus pruning, the direct DFS search will time out, the optimization method is in the search is a priority to get out of the small path, such as move1 and Move2 can walk, but as the move1 after the next step there are 7 ways to walk, and go after the move2 there are 2 ways to go, Then we'll take the priority move2, the specific imp
Hdu 1445 dfs pruning, hdu1445
The meaning of the question is relatively simple; the focus is on pruning.
# Include Using namespaceStd; IntN,Num[70],Mark[70],K,Flash; IntDfs(IntS, IntIi, IntT, IntC) {If (T=C){Flash=1; Return1;} If (Flash) Return0; If (S=K){Dfs(0,1,T+1,C);// Return 1;} Else {intI; (I=Ii;IN;I++) {If (S+Num[I]>K) Continue; if (Mark[I]) Continue;Mark[I] =1;Dfs(S+Num[I],I+1,T,C);Mark[I] =0; If
HDU 4876 ZCC loves cards (brute force pruning), hduzccHDU 4876 ZCC loves cards
Question Link
Given some cards with numbers on each card, select k cards and wrap them into a ring. You can choose 1-k cards on the ring each time, obtain the number of their exclusive or sum. Given an L, ask the maximum value of R when [L, R] is composed of all numbers.
Idea: brute-force C (20, 6), and then simulate the calculated value after each sequence is deprecated to
input consists of multiple test cases. the first line of each test case contains three integers n, m, and T (1 The next n lines give the maze layout, with each line containing M characters. A character is one of the following:
'X': a block of wall, which the doggie cannot enter;'S ': the start point of the doggie;'D': the door; or'.': An empty block.
The input is terminated with three 0's. This test case is not to be processed.
Outputfor each test case, print in one line "yes" if the dogg
.
Input
The input consists of multiple test cases. the first line of each test case contains three integers n, m, and T (1 Maze layout, with each line containing M characters. A character is one of the following:
'X': a block of wall, which the doggie cannot enter;'S ': the start point of the doggie;'D': the door; or'.': An empty block.
The input is terminated with three 0's. This test case is not to be processed.
Output
For each test case, print in one line "yes" if the doggie can have ve, or "
Acdream 1726 A Math game (partial and problematic DFS pruning), acdreamdfs
A Math gameTime Limit: 2000/1000 MS (Java/Others)
Memory Limit: 256000/128000 KB (Java/Others) Problem DescriptionRecently, Losanto find an interesting Math game. The rule is simple: Tell you a number
H, And you can choose some numbers from a set {a [1], a [2],..., a [n]}. if the sum of the number you choose is
H, Then you win. Losanto just want to know whether he can win the g
SquareTime limit:10000/5000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 13374 Accepted Submission (s): 4244Problem 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 Input
possible, because their data are not over, there is no submission
As for the evaluation of the time I think the direct STL is good, hash try itI was speechless when I saw the answer.
Backtracking and pruning.
1#include 2#include 3#include 4#include 5#include 6#include 7#include 8 #defineINF 0x3f3f3f3f9 using namespacestd;Ten One intn,vis[ -]; A Doubleans=INF; - - structcc{ the Doublex, y; -}nod[ -]; - - DoubleDisintAintb) { + retu
The main topic: Give a grid matrix, the matrix has a number 0~9, choose a lattice as the starting point, will walk through the numbers together to form a number, find the largest number, each lattice can only walk once.Topic Analysis: DFS. Pruning scheme: In the current situation, find out all the number of points can also be reached, if the length of the current number is still less than the length of the current optimal answer, then cut away; If the
starting with X forThe given positive integer n. Products and quotients appearinginchThe sequence should is x to a positive integer ' s power. In others words, x−3, forExample, should never appear.Input is is + is indicated by a zero.Output for inch as leading or trailing spaces.Sample Input1 to - the 473 + 811 953 0Sample Output0 6 8 9 One 9 - ASourceJapan 2006Find out how many steps you can take with multiplication and division to get X^nIn fact, the answer is up to 13, but since t
UVA 10245 the Closest Pair problemThe main topic: give n points, to find out the distance between the nearest two points. If the distance between points and points is greater than 10000, the output infinityproblem-solving ideas: The Orthodox approach to this problem is to divide and treat, lazy method is violence plus pruning. Sort by x-coordinate first, then Fabs (P[i]-p[j]) > ans points can be skipped directly. #include UVa 10245 The Closest Pair p
Title Link: BZOJ-1082Problem analysisTwo points + DFS authentication.Two points to a mid, to verify the choice of mid-root sticks, it is obvious to choose the smallest mid root.Use DFS authentication, because greedy to think about it, to try to first use the small wooden sticks provided, as far as possible first to make the need for the big stick, so to first will provide the sticks and the need to sort the sticks.DFS is based on the need of sticks from the big to the small order of one layer at
ChannelTest instructions: Give a 1-letter tree asking if a string appears in the treeIdea: Direct Search pruning, people point division? Wrote a few hair is t. Somebody's going to teach me?Code:#include #include#includeusing namespacestd;structEdge {intV, NXT; Edge () {} Edge (int_v,int_n) {v= _v, NXT =_n; }};Const intMax_n =10007;intHead[max_n], N, Len, ecnt, Tim;CharA[max_n], b[max_n];intDis[max_n], F[max_n], vis[max_n]; Edge G[max_n1];voidinit () {
Dfs+ pruning ...Before each DFS, half of the current checkerboard's grid size is less than the number of one color to cut offBlack and WhiteTime limit:2000/2000 MS (java/others) Memory limit:512000/512000 K (java/others)Total submission (s): 194 Accepted Submission (s): 50Special Judge Problem DescriptionIn Mathematics, the four-color theorem, or the four-color map theorem, states, given any separatio N of a plane into contiguous regions, producin
Seeing Next_permutation seems to be able to ╮(╯▽╰)╭.The learning point of this question:1. Map mapping2. Guaranteed minimum dictionary order by sequencing enumeration3.STRTOK,SSCANF,STRCHR and other functions have been reviewed again, although the program is not actually used4. Pruning, or backtracking#include using namespacestd;intg[8][8],deg[8];BOOLvg[8][8];//Interpreting Connectivityintpos[8];BOOLvis[8];intK;intbest[8];intCNT;intid[ -];Charrev_id[8
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.