HDU 4035 Maze probability dp + tree dp, hdu4035
Question: Click the open link.
#include
200 dynamic planning details
Well, I haven't learned this for a long time. I am also confused. I guess I just got started two months ago ......You can see that what he wrote is ineffective and what the optimal sub-structure is. I am also too large ............Dynamic Planning generally solves two types of problems:
... Repair changes to WA four after finally AC, output the entire path I see most of the work is Father Array, Ang, I think I still cherish the opportunity to use the stack1#include 2#include string.h>3#include 4#include 5 using namespacestd;6 7 structcity{8 intv,l;9}c[101];Ten /* One BOOL CMP (city c1,city C2) { A return c1.v - } - */ the BOOLg[101][101]; - intdp[101]; - - intMain () { + intT; - while(SCANF ("%d", t)! =EOF) { + for(intq=1; q){ AMemset (G,0,sizeof(g)); at
Test instructions: N Programmers write M-line code together, the first programmer each write a line has a[i] a bug, the total bug is not more than the allocation of the B number of optionsAnalysis: The problem is quite like a complete backpack, but not the maximum/minimum number of bugs, the number of bugs is less than the upper limit of the allocation scheme. So the problem is to use three-dimensional DPDp[i][j][k] indicates that the first I all programmers wrote the J line code produced a K bu
! Hdu 1203 -- dp -- (deep understanding), hdu1203 -- dp --
James has n yuan. He wants to apply for a foreign school and apply for the si fee for the I-th school. The probability of successful application is pi, the probability that James can apply for at least one school.
Analysis: the probability is, of course, the minimum value from the opposite side. State transition equation:
Http://codeforces.com/problemset/problem/414/BDefine a string as a good string when this string conforms to the Di|di+1,1Given an n is the range of the elements in the string, a k is the length of the string, calculating all possible counts of the string.I started thinking about it. Dp[i][j] I represents the length of a string, and J represents the number of strings with a length of I ending with J.But I think it's crooked. I'm thinking of introducing
Missile: Dual-state DP, missile state dpQuestion
Description
Long, long ago, country A specified Ted a missile system to destroy the missiles from their enemy. that system can launch only one missile to destroy multiple missiles if the heights of all the missiles form a non-decrease sequence.
But recently, the scientists found that the system is not strong enough. so they invent another missile system. the new system can launch one single missile to d
Test instructions: give you a string of length 1000 and a number n let you put in the string '? ' Fill in the number so that the string is a multiple of N and the smallest (no preamble 0)The Dp[len][mod] is the state of the MoD (dp=0 or 1) for the presence of the first Len bitImplemented with a mnemonic search, DFS returns 1 or 0.If the last one is searched and the remainder is 0, return 1.If you search for
Kuangbin Special Links: Http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68966#problem/A
Test instructions: Maximum m sub-segment problem: the number of intervals given without crossing is obtained, and the maximum and value are obtained.
See, N reached 1000000, the heart of the first idea is only one-dimensional DP problem, but in the derivation of the state transfer formula, you have to use two-dimensional
Longest Common subsequence DP and longest sequence dp
An algorithm instructor's assignment, a basic dp question, gives you two sequences and asks you what the longest common subsequences are, for example, (a, B) is (a, c, d, B). Note that it is not the longest public substring, And the subsequence here can be discontinuous.
Two for loops come out, each
Hdu 1561 tree dp, hdu1561 tree dp
Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 1561
Problem DescriptionACboy enjoys playing a strategic game. on a map, there are N castles, each of which has certain treasures, in each game, ACboy allows him to conquer M castles and gain the treasures in them. However, due to the geographical location, some castles cannot be directly conquered. To conquer these castles, y
Hdu1011 tree dp backpack and hdu1011 tree dp backpack
Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 1011
Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. the base is built underground. it is actually a huge cavern, which consists of specified rooms connected with tunnels. each room is occupied by some bugs, and their brains hide in some of the rooms. scienti
Test Address: Treasureprocedure: The subject needs to use the pressure DP.The Order DP (I,J) d p (i, J) DP (I,J) is the depth for I I, the developed room state is the minimum cost of J J J, then we enumerate the set K K K that does not intersect with J J J, so we can transfer the state:DP (I+1,J+K) =min (DP (I+1,J+K), DP
Question link: http://poj.org/problem? Id = 2411
Given a square rectangle of N * m, calculate the number of solutions completely covered by a small rectangle of 1*2, n
Solution: a typical type of State DP is that the child rectangle covers the parent rectangle. This type of DP compresses the 01 state of a row and transfers it by row.
In this question, the value 0 in each column indicates that it is not co
Crazy thairs
Time limit:3000 Ms
Memory limit:65536 K
Total submissions:6598
Accepted:1636
Description
These days, sepageris crazed on one problem named Crazy Thair. GivenN(1 ≤N≤ 50000) numbers, which are no more than 109, crazy Thair is a group of 5 numbers {I,J,K,L,M} Satisfying:
1. 1 ≤IJKLM≤N2.AIAJAKAlAM
For example, in the sequence {2, 1, 3, 4, 5, 7, 6}, there are four crazy Thair groups: {1, 3, 4, 5, 6}, {2, 3, 4, 5, 6}, {1, 3, 4, 5, 7} and {2, 3, 4, 5,
What is the slope dp? I'm probably going to drop some of the monotone packet problems from O (n^2) to O (N) Specifically, I'm not going to say much. Read the paper:Http://www.cnblogs.com/ka200812/archive/2012/08/03/2621345.htmlI will add a few words myself:In fact, there are many kinds of slope DP play has a convex hull has a direct comparison of the slope because I am weak, so the most mentally retarded co
Given a tree with n nodes, calculate the minimum difference between the two branches after deleting an edge.
Solution: Tree DP. the first deep search record the total number of child nodes (including the current node) from the current node (including the current node), the first time the pre-processing is calculated, the complexity is O (N ), for the second time, use the first result to find the minimum difference value after removing an edge. The ans
Test instructionsGive you n a string, n (1 Ask not to disturb the string order, take several strings from it, so that the previous string is the substring of the latter string, to satisfy the preceding conditions of the string is worth and maximum, to find this value.Ideas:is actually a very obvious DP.Dp[i] represents the maximum weight at the end of the first string.But that's the problem with the substring.Because this data compares water can use suffix array to deal with this problem.Stitch
Zoj 3640 probability dp, zoj3640 probability dp
Http://acm.zju.edu.cn/onlinejudge/showProblem.do? ProblemId = 4808
Background
If thou doest well, shalt thou not be accepted? And if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him.And Cain talked with Abel his brother: and it came to pass, when they were in the field, that Cain rose up against Abel
Hdu3709 digital dp (self-balancing number), hdu3709 digital dp number
Http://acm.hdu.edu.cn/showproblem.php? Pid = 1, 3709
Problem DescriptionA balanced number is a non-negative integer that can be balanced if a partition is placed at some digit. more specifically, imagine each digit as a box with weight indicated by the digit. when a distance is placed at some digit of the number, the distance from a digit
POJ--2923 -- Relocation -- pressure DP, pressure dp
Relocation
Time Limit:1000 MS
Memory Limit:65536 K
Total Submissions:2288
Accepted:950
Description
Emma and Eric are moving to their new house they bought after returning from their honeymoon. fortunately, they have a few friends helping them relocate. to move the furniture, they only have two compact cars, which comp
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.