DP
脑回路清奇的少年
这个作者很懒,什么都没留下…
展开
-
Common Subsequence (LCS最大公共串模版题)POJ - 1458
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...原创 2018-04-06 14:55:28 · 212 阅读 · 0 评论 -
Alphacode (动态规划思想)POJ - 2033 HDU - 1508
Alice and Bob need to send secret messages to each other and are discussing ways to encode their messages: Alice: "Let's just use a very simple code: We'll assign 'A' the c...原创 2018-04-02 23:36:53 · 538 阅读 · 0 评论 -
Partitioning by Palindromes UVA - 11584(最小回文串分解DP)
We say a sequence of charactersis a palindrome if itis the same written forwardsand backwards. For example,‘racecar’ is a palindrome, but‘fastcar’ is not. A partition of a sequence ofcharacters...原创 2018-04-15 01:14:07 · 178 阅读 · 0 评论 -
HDU-1069 Monkey and Banana [DP -> 二维最长上升串]
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monk...原创 2018-04-29 04:10:03 · 143 阅读 · 0 评论 -
CodeForces - 364B Free Market (Dp+贪心思想结合 )
John Doe has recently found a "Free Market" in his city — that is the place where you can exchange some of your possessions for other things for free. John knows that his city has n items in total (ea...原创 2018-05-27 22:00:24 · 266 阅读 · 0 评论 -
HDU - 1078 FatMouse and Cheese (DP+记忆化搜索)
FatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At each grid ...原创 2018-06-05 23:15:52 · 166 阅读 · 0 评论 -
Prince and Princess UVA - 10635(动态规划专题 LIS+Hash )
求两个数字串的最长公共子列,但是要注意,这里的n高达250^2=62500,LCS的复杂度为N^2,明显会超时。因为每个数字不重复,故可以建立从A到B的映射(若未在A中出现过,则记为0),将问题转化为LIS,即求B的最长上升子串,复杂度为N*log(N)。Code:#include<cstdio>#include<cstring>#include<cmath>...原创 2018-06-06 02:42:23 · 190 阅读 · 0 评论 -
CodeForces - 8C Looking for Order (两种方法的实现:状压DP,DFS)
Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag...原创 2018-06-30 00:17:59 · 404 阅读 · 0 评论 -
HDU 4778 Gems Fight!(博弈+状压DP)
Problem Description Alice and Bob are playing "Gems Fight!": There are Gems of G different colors , packed in B bags. Each bag has several Gems. G different colors are numbered from color 1 t...原创 2018-10-25 20:10:25 · 187 阅读 · 0 评论