Dynamic programming question bank

1. Simple basic dp

This type of dp is mainly because some states are easier to represent, the transition equation is easier to think, and the problems are relatively common. It mainly includes recursion, backpack, LIS (longest increasing sequence), and LCS (longest common subsequence). For these types, we recommend better learning materials and topics.

1. Recursion:

The general form of recursion is relatively simple. From front to back, it is enough to classify and enumerate.

Simple:

hdu 2084 number tower is simply recursive from top to bottom

hdu 2018 cow story simple recursive count

hdu 2044 A little bee... Simple recursive counting (Fibonacci)

hdu 2041 Super Staircase Fibonacci

hdu 2050 polyline dividing plane to find recursive formula

recommend:

CF 429B B.Working out Four corners recursion

zoj 3747 Attack on Titans Count recursive dp with constraints

uva 10328 Coin Toss Same as above

hdu 4747 Mex

hdu 4489 The King's Ups and Downs

hdu 4054 Number String


2. Backpack

Nine lectures on the classic backpack: http://love-oriented.com/pack/

Recommended blog: http://blog.csdn.net/woshi250hua/article/details/7636866

There are mainly 0-1 backpacks, complete backpacks, grouped backpacks, and multiple backpacks.

Simple:

hdu 2955 Robberies 01 Backpack

hdu 1864 maximum reimbursement 01 backpack

hdu 2602 Bone Collector 01 Backpack

hdu 2844 Coins Multipack

hdu 2159 FATE complete backpack

recommend:

woj 1537 A Stone-I converted into backpack

woj 1538 B Stone-II converted into backpack

poj 1170 Shopping Offers Shape Press + Backpack

zoj 3769 Diablo III backpack with constraints

zoj 3638 Transformation of Fruit Ninja backpack into combinatorics

hdu 3092 Least common multiple transformed into a complete knapsack problem

poj 1015 Jury Compromise extended range + output path


3、LIS

The longest increasing subsequence, the naive o(n^2) algorithm, can be written as o(nlgn) under the bisection: maintain a current optimal increasing sequence - find the update just larger than it

Simple:

hdu 1003 Max Sum

hdu 1087 Super Jumping!

recommend:

uva 10635 Prince and Princess LCS converted to LIS

hdu 4352 XHXJ's LIS digital dp+LIS idea

srm div2 1000 state compression + LIS

poj 1239 Increasing Sequence twice dp


4、LCS

Longest common subsequence, usually O(n^2) algorithm

hdu 1503 Advanced Fruits

hdu 1159 Common Subsequence

uva 111 History Grading must be sorted first

poj 1080 Human Gene Functions


Second, the interval dp

Recommended blog: http://blog.csdn.net/woshi250hua/article/details/7969225

The interval dp is generally an enumeration interval, which divides the interval into left and right parts, and then finds the left and right intervals and then merges them.

poj 1141 Brackets Sequence bracket matching and output scheme

hdu 4745 Two Rabbits converted into a palindrome string

zoj 3541 The Last Puzzle greedy + interval dp

female 2955 Brackets

hdu 4283 You Are the One Common Spelling

hdu 2476 String Printer

zoj 3537 Cake

CF 149D Coloring Brackets

zoj 3469 Food Delivery


Three, tree dp

Better blog: http://blog.csdn.net/woshi250hua/article/details/7644959

A paper: http://doc.baidu.com/view/f3b19d0b79563c1ec5da710e.html

The tree-shaped dp is a dp built on the data structure of a tree. The general state is better to think about, and the state transition from root to leaf or from leaf to root is maintained through dfs.

hdu 4514 find the diameter of a tree

poj 1655 Balancing Act

hdu 4714 Tree2Cycle Thoughts

hdu 4616 Game

hdu 4126 Genghis Kehan ​​the Conqueror MST+ tree dp is more classic

hdu 4756 Install Air Conditioning MST+ tree dp as above

hdu 3660 Alice and Bob's Trip is a bit like adversarial search

CF 337D Book of Evil Tree Diameter Thought Thinking

hdu 2196 Computer Search twice


4. Digital dp

Recommend a paper: http://wenku.baidu.com/view/d2414ffe04a1b0717fd5dda8.html

Digital dp is mainly used to count the number of numbers in an interval that satisfies a certain kind of special relationship or has certain characteristics. After a lot of digital dp is done, the routines are basically the same. The key is to abstract the state to be saved and save it.

hdu 2089 not 62 simple digital dp

hdu 3709 Balanced Number is relatively simple

CF 401D Roman and Numbers shape + digital dp

hdu 4398 X mod f(x) add the modulo to the state

hdu 4734 F(x) simple digital dp

hdu 3693 Math teacher's homework digital dp for mind transformation

hdu 4352 XHXJ's LIS digital dp+LIS idea

CF 55D Beautiful Numbers is a more ingenious digital dp

hdu 3565 Bi-peak Numbers is hard to imagine

CF 258B Little Elephant and Elections Digital DP + Combinatorics + Inverse Elements


5. Probability (expectation) dp

Recommended blog: http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710606.html

Recommended blog: http://blog.csdn.net/woshi250hua/article/details/7912049

Recommended papers:

"Into the World of Probability"

"Analyzing the Solutions to a Kind of Mathematical Expectation Problems in Competitions"

"Research on Probability and Expectation Problems"

Generally speaking, the probability is pushing forward, and the expectation is pushing backward. Generally, Gaussian elimination is used to solve equations with rings. The expectation can be decomposed into a weighted sum of multiple sub-expectations, where the weight is the probability that the sub-expectations occur, ie E(aA+bB+...) = aE(A) + bE(B) +...

ural 1776 Anniversiry Firework Comparative Basics

hdu 4418 Time travel comparison of classic BFS + probability dp + Gaussian elimination

hdu 4586 Play the Dice push formula comparison water

hdu 4487 Maximum Random Walk

jobdu 1546 Maze problem Gaussian elimination + probability dp + BFS preprocessing

hdu 3853 LOOPS simple probability dp

hdu 4405 Aeroplane chess simple probability dp, more direct

hdu 4089 Activation is more classic

poj 2096 Collecting Bugs topic is difficult to read

zoj 3640 Help me Escape from back to front, relatively simple

hdu 4034 Maze classic good question, with the help of tree probability dp

hdu 4336 Card Collector state compression + probability dp


Six, state compression dp

Such problems include TSP, plug dp, etc.

Recommended papers: http://wenku.baidu.com/view/ce445e4f767f5acfa1c7cd51.html

Recommended blog: http://blog.csdn.net/sf____/article/details/15026397

Recommended blog: http://www.notonlysuccess.com/index.php/plug_dp/

hdu 4568 Hunter shortest path + TSP

hdu 4539 plug dp

hdu 4529 shape pressure dp

poj 1185 artillery position

hdu 3811 Permutation

poj 2411 Mandriann's Dream

single 1038

single 2441

hdu 2167

hdu 4026

hdu 4281


Seven, data structure optimization dp

Sometimes even though the state is found and the transition equation is well thought out, the time complexity is relatively large, and the data structure needs to be used for optimization. Common optimizations include binary optimization, monotonic queue optimization, slope optimization, quadrilateral inequality optimization, etc.

1. Binary optimization

The main problem is to optimize the backpack. There is an introduction in the nine lectures on the backpack, which is relatively simple. Only a few questions are attached here.

hdu 1059 Diving

hdu 1171 Big Event in Hdu

poj 1048 Follow My Magic

2. Monotonic queue optimization

Recommended papers: http://wenku.baidu.com/view/4d23b4d128ea81c758f578ae.html

Recommended blog: http://www.cnblogs.com/neverforget/archive/2011/10/13/ll.html

hdu 3401 Trade

poj 3245 Sequece Partitioning binary + monotonic queue optimization

3. Slope optimization

Recommended paper: Optimizing Dynamic Programming with Monotonicity

Recommended blog: http://www.cnblogs.com/ronaflx/archive/2011/02/05/1949278.html

hdu 3507 Print Article

poj 1260 Pearls

hdu 2829 Lawrence

hdu 2993 Max Average Problem

4. Quadrilateral inequality optimization

Recommended blog: http://www.cnblogs.com/ronaflx/archive/2011/03/30/1999764.html

Recommended blog: http://www.cnblogs.com/zxndgv/archive/2011/08/02/2125242.html

hdu 2952 Counting Sheep

poj 1160 Post Office

hdu 3480 Division

hdu 3516 Tree Construction

hdu 2829 Lawrence

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325861000&siteId=291194637