Introduction to algorithm competitions: typical Dynamic Programming and dynamicprogramming

Source: Internet
Author: User

Introduction to algorithm competitions: typical Dynamic Programming and dynamicprogramming

111-History Grading LCA

103-Stacking Boxes DAG longest path

10405-Longest Common Subsequence LCA

674-Coin Change full backpack solution count

Simple recursive output lexicographically explain solution from the back forward

10130-SuperSale 01 backpack

531-Compromise LCA

10465-Homer Simpson full backpack

10285-Longest Run on a Snowboard ski classic memory search

437-The Tower of Babylon longest ascending sequence LIS

10404-Bachet's Game full backpack

? 620-Cellular Structure

825-Walking on the Safe Side direct top left to bottom right

 

 

 


ACM Dynamic Planning (algorithm competition entry-level classic)

Recursion is not enough. It is obvious that the logic structure of the stack needs to be maintained. The personal opinions on recurrence and DP are for reference only.

DP = State + state transition equation
The key feature of the status is no aftereffect. For example, in a project of the Olympic Games, the score is only related to the next competition, and the previous score is not included (only the competition system is considered ). If you find that the status information of the previous stage is used for decision-making after a state, this is not a standard DP. For example:
A-B1-C1-D
\ -- EX ------/
If EX is categorized into B or C segments, the EX-D or A-EX jumps over a stage where the state information of the previous phase is used
Of course, this does not mean that the DP algorithm cannot be used. For the above example, you can split EX into B2-C2 to meet the DP conditions. For continuous DP, similar adjustments are more.

The state transition equation is the decision of the State to the State.
Simply put, it is the greedy part. You can choose one path from multiple paths.

In many cases, recurrence and DP are difficult to distinguish. In general, State transfer decisions are considered as "DP" when they are "selected". If the computing proportion is large, it is considered as recurrence; when the status is adjusted for a large number of times, it may be regarded as a recurrence; the continuous status can be classified as DP.
For example, M * N carries a weight grid, from top left to bottom right. Each time, only one grid can be moved to the right or bottom, and the sum of weights and the maximum (small) number of paths can be obtained.

Another word is "recursive planning". If you are interested, you can read the relevant information.

After the explanation, the answer is obvious: DP must have a state transition equation. It can be said that the key to DP is the state transition equation.
Your first question, I hope you will report the title of the book. It seems that I have no white skin.

How to get started with algorithm Competitions

From the arrangement of books, we can see that the author is writing books with heart. For example, in the dynamic planning chapter, all the algorithm books I have seen currently only give the value of the optimal value when introducing the basic problems of dynamic planning, the answer construction needs are not taken into account in competitions or other needs. For example, if a question really requires you to output the solution with the smallest dictionary sequence, it may be difficult for many people. It takes a lot of time for beginners to comprehend these methods. There are still many such hard books. The authors use algorithms to give some tips, but they feel good when beginners are prone to mistakes. Even more valuable, as a silver medalist in icpc world final and coach of the National Informatics team, the author is not on the shelf, there will be no direct examples like the "obvious" and "easy to see" in the high numbers and scores. However, this does not mean that the industry is arrogant. On the contrary, it reflects the delicate mind of the author. When I go to PKU to do two questions, I find that the algorithm is correct in many cases, there is no error in details in another aspect. coding "=" into "=" and calling the code for more than an hour is definitely a common mistake when you are a beginner. However, the whole book does not have any bibliography attached to the appendix. First, it does not respect the authors of the referenced books. Second, it is not conducive to further reading by readers (for example, exercise recommendations after the dynamic planning chapter, it is basically all from the exercises in programming challenge ). In general, this book is definitely worth reading, even an ACMER with an algorithm base. | OIer looks forward to the release of the next two books

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.