
ACM-动态规划
文章平均质量分 85
动态规划算法题
_txg
平凡,是为了最美的荡气回肠
展开
-
HDU - 4455 (DP)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4455XXX has an array of length n. XXX wants to know that, for a given w, what is the sum of the distinct elements’ number in all substrings of lengt原创 2017-10-23 21:31:12 · 1199 阅读 · 0 评论 -
poj 1260 Pearls
题目链接:点击打开链接DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its name because it delive原创 2016-08-18 20:02:30 · 270 阅读 · 0 评论 -
poj 1159 Palindrome
题目链接:点击打开链接DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a strin原创 2016-08-18 20:07:45 · 395 阅读 · 0 评论 -
poj 1080 Human Gene Functions
题目链接:点击打开链接DescriptionIt is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists h原创 2016-08-18 20:12:41 · 252 阅读 · 0 评论 -
poj 1276 Cash Machine
题目链接:点击打开链接DescriptionA Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct原创 2016-08-23 19:08:16 · 301 阅读 · 0 评论 -
CodeForces - 2B -The least round way (dp math)
点击链接:http://codeforces.com/problemset/problem/2/BThere is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it thatstarts in the upper left cell原创 2017-01-11 14:42:19 · 498 阅读 · 0 评论 -
poj 1191 棋盘分割(dp)
点击链接:http://poj.org/problem?id=1191Description将一个8*8的棋盘进行如下分割:将原棋盘割下一块矩形棋盘并使剩下部分也是矩形,再将剩下的部分继续如此分割,这样割了(n-1)次后,连同最后剩下的矩形棋盘共有n块矩形棋盘。(每次切割都只能沿着棋盘格子的边进行) 原棋盘上每一格有一个分值,一块矩形棋盘的总分为其所含各格分值之和。现在原创 2017-01-13 15:17:34 · 505 阅读 · 0 评论 -
ZOJ - 3777 Problem Arrangement(状态压缩dp)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the o原创 2017-01-15 16:13:41 · 426 阅读 · 0 评论 -
poj 3280 Cheapest Palindrome(区间dp)
点击:http://poj.org/problem?id=3280DescriptionKeeping track of all the cows can be a tricky task so Farmer John has installed a system to automate it. He has installed on each cow an electronic原创 2017-01-16 11:08:24 · 343 阅读 · 0 评论 -
poj 1836 Alignment
题目链接:点击打开链接DescriptionIn the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not s原创 2016-08-18 19:59:14 · 361 阅读 · 0 评论 -
poj 1837 Balance
题目链接:点击打开链接DescriptionGigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance. It orders two arms of negligible weight and e原创 2016-08-18 19:37:24 · 364 阅读 · 0 评论 -
HDU - 4495 (字符串哈希+二分+DP)
传送门:点击打开链接Given a rectangle which contains N rows and each of them contains a string length of M. You must find out a symmetrical isosceles right triangle (with two equal edges and a right ang原创 2017-10-23 13:33:44 · 521 阅读 · 0 评论 -
POJ 2955 _Brackets (区间Dp)
传送门:http://poj.org/problem?id=2955BracketsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8881 Accepted: 4763DescriptionWe give the following原创 2017-08-24 10:53:07 · 260 阅读 · 0 评论 -
Gym - 100269F Flight Boarding Optimization (dp+树状数组或线段树预处理)
传送门:http://codeforces.com/gym/100269/attachments题目大意:有n个点r[i],r[i]k部分,每部分的r[i]值是在一个连续的区间内的,但是他们在n数组中的相对位置不变,求总的最小权值是多少。题解:首先处理出(以下的“区间”均表示r[i]值的)当区间【i,j】单独一部分的时候的权值sum[i][j]。然后再dp[i][j]表示以i为原创 2017-08-04 22:10:27 · 370 阅读 · 0 评论 -
HDU_4352 _ XHXJ's LIS (数位Dp+LIS + 状压)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4352XHXJ's LISTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3052 Accepted Submissio原创 2017-08-16 19:41:06 · 395 阅读 · 0 评论 -
poj 3267 The Cow Lexicon
题目链接:点击打开链DescriptionFew know that the cows have their own dictionary with W (1 ≤ W ≤ 600) words, each containing no more 25 of the characters 'a'..'z'. Their cowmunication system, based on mo原创 2016-08-03 19:34:38 · 358 阅读 · 0 评论 -
poj 2533 Longest Ordered Subsequence
题目链接:点击打开链接DescriptionA numeric sequence of ai is ordered if a1 a2 aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1,ai2, ..., aiK), where 1 i1 i2 <原创 2016-08-04 21:27:19 · 257 阅读 · 0 评论 -
poj 3176 Cow Bowling
题目链接:点击打开链接ps;简单DP, 数字三角形#include #includeusing namespace std;int a[400][400];int main(){ int n; cin>>n; for(int i=0;i<n;i++) { for(int j=0;j<=i;j++) {原创 2016-08-04 21:28:35 · 282 阅读 · 0 评论 -
poj 2151 Check the difficulty of problems
题目链接:点击打开链接DescriptionOrganizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following two原创 2016-08-08 20:12:38 · 272 阅读 · 0 评论 -
poj- 2029 -Get Many Persimmon Trees (DP)
http://poj.org/problem?id=2029DescriptionSeiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him f原创 2017-02-07 09:55:41 · 345 阅读 · 0 评论 -
poj 1925_Spiderman(坐标DP)
http://poj.org/problem?id=1925DescriptionDr. Octopus kidnapped Spiderman's girlfriend M.J. and kept her in the West Tower. Now the hero, Spiderman, has to reach the tower as soon as he can to原创 2017-02-08 14:01:04 · 559 阅读 · 0 评论 -
poj 2948 Martian Mining
http://poj.org/problem?id=2948DescriptionThe NASA Space Center, Houston, is less than 200 miles from San Antonio, Texas (the site of the ACM Finals this year). This is the place where the astr原创 2017-02-08 14:33:19 · 318 阅读 · 0 评论 -
Brackets sequence UVA - 1626 (典型的区间dp+递归打印路径)
点击链接哦:https://vjudge.net/problem/51187/origin题目大意:括弧的序列,在一个字符串中只包含" ( " " ) "和“ [ ” “ ] ”,要求空序列为正确的括弧,如果s是正确的序列,那么[s]和(s)也是正确的序列,如果a和b是是正确的序列,那么ab也是正确的序列。Brackets sequence UVA - 1626 (典型的区间dp+递归打印路径)原创 2017-03-17 16:51:57 · 389 阅读 · 0 评论 -
hiho #1482 : 出勤记录II(DP)
时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Hi的算法课老师每次上课都会统计小Hi的出勤记录。迟到会被记录一个L,缺席会被记录一个A,按时上课会被记录一个O。一学期结束,小Hi的出勤记录可以看成是一个只包含LAO的字符串,例如"OOOOLOOOLALLO……"。如果小Hi整学期缺席不超过1次,并且没有连续3次迟到,小Hi的原创 2017-03-20 17:36:24 · 944 阅读 · 0 评论 -
2016山东省第七届ACM省赛-部分题解
sdut-3560-julyed:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/3560.htmlJulyedProblem Description Julyed is preparing for her CET-6. She has N words to rememb原创 2017-04-11 10:35:15 · 2457 阅读 · 0 评论 -
2017sdut省赛选拔(1)--poj1631-(nlogn的最长上升子序列)
http://poj.org/problem?id=1631Bridging signalsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 14108 Accepted: 7630Description'Oh no, they've don原创 2017-04-11 11:13:58 · 382 阅读 · 0 评论 -
2017sdut省赛选拔(1)--poj3279(状态压缩+枚举)
http://poj.org/problem?id=3279FliptileTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 9642 Accepted: 3597DescriptionFarmer John knows that an原创 2017-04-11 15:52:37 · 446 阅读 · 0 评论 -
2017省选拔(三)poj 1222 EXTENDED LIGHTS OUT (状态压缩+枚举反转)
点击打开链接In an extended version of the game Lights Out, is a puzzle with 5 rows of 6 buttons each (the actual puzzle has 5 rows of 5 buttons each). Each button has a light. When a button is pressed原创 2017-04-19 11:26:23 · 338 阅读 · 0 评论 -
2017省选拔(三)poj2392 Space Elevator
题目链接:点击打开链接The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which原创 2017-04-19 12:03:47 · 366 阅读 · 0 评论 -
hdu 3001 Travelling (TSP问题,状压dp)
After coding so many days,Mr Acmer wants to have a good rest.So travelling is the best choice!He has decided to visit n cities(he insists on seeing all the cities!And he does not mind which city being原创 2017-05-19 18:38:16 · 1282 阅读 · 0 评论 -
Optimal Array Multiplication Sequence UVA - 348 (最优矩阵链乘+递归输出路径+区间dp)
题目链接:https://vjudge.net/problem/19208/origin题目大意:对于一个a*b和b*c的矩阵相乘的结果为a*b*c, 如果有三个矩阵相乘就是a*b b*c c*d 这三个矩阵相乘,因为满足结合律,所以可以先乘后两个,再和第一个相乘。由于先乘那一对矩阵决定了运算量的大小,所以让你计算怎么结合相乘能使得运算量最小。那么什么是运算量的大小呢:比如有三个矩阵为原创 2017-03-17 16:25:08 · 390 阅读 · 0 评论 -
Cutting Sticks UVA - 10003 (区间Dp)
链接:点击打开链接题目大意:有一根木棍长度为L,然后有N个切割点,将木棍切割成n+1段,当切割长度为Li时,那么需要Li的费用.例如有一个长度为10的木棍,切割点在2,4,7位置上,如果顺序切割的话: 1、首先长度为10,在2位置切割,那么sum+=102、再在剩下的长度为8的长度中切割4位置,那么sum+=83、再在剩下长度为6中切7位置,那么sum+=6==24而如果按顺序原创 2017-03-15 21:39:00 · 384 阅读 · 0 评论 -
poj 3254 Corn Fields(状压dp)
http://poj.org/problem?id=3254DescriptionFarmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn f原创 2017-02-10 10:57:31 · 315 阅读 · 0 评论 -
cf - 777C-Alyona and Spreadsheet(预处理)
During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables.Now she has a table filled with integers. The table consists of n rows and m co原创 2017-02-24 20:46:47 · 571 阅读 · 0 评论 -
The Tower of Babylon UVA - 437 (DAG上的动态规划变形,记忆化搜索)
Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this talehave been forgotten. So now, in line with the educational nature of this contest, we will tell you thewh原创 2017-03-10 21:43:08 · 405 阅读 · 0 评论 -
A Spy in the Metro UVA - 1025 (dp)
原题目不好复制,就不贴了!题目大意:(紫书的题意)某城市的地铁是线性的,有n(2 输入第一行为n, 第二行为T; 第三行有n-1个整数t1,t2---表示从i->i+1车站的时间 第四行为M1 第五行为M1个数d1---dM1表示各列车的发车时间 第六行 M2 M2个d 题解:影响决策的只有当前时间和所处的车站,所以d(i,j)表示时原创 2017-03-10 22:02:27 · 281 阅读 · 0 评论 -
Tour UVA - 1347 (DP)
https://vjudge.net/problem/38898/origin题目大意和题解过程详见紫书p269ps:我只说一下自己的理解: 首先这个题有一个关键词是“输入的数据是根据x坐标的顺序输入的且没有重复的”,那么这说明要想把这个多变形链接起来,那首先得有一条路径从起点到终点,在有一条路径从终点到起点。相当于从起点有两条路径到达终点。那么要想让这两条路径最短该怎么办呢? 可以肯原创 2017-03-13 22:16:37 · 310 阅读 · 0 评论 -
Jin Ge Jin Qu hao UVA - 12563 (0-1背包变形)
点击打开链接题目大意:某人在KTV唱歌,他一共剩余t秒的时间,例如:在还有15秒时再唱一首2分钟的歌,则实际上是多唱了105秒。他一定会在最后唱《Jin Ge Jin Qu》时长678秒,当然是在还有剩余时间的时候开始唱的。在剩余的t秒里,他有n首自己喜欢的歌要唱,给出n首歌的时长。问要使得唱的曲目尽量的多,且多唱的时间尽量的多是多少;具体题意看链接或紫书。输出唱的曲目数和唱的时间数。原创 2017-03-14 17:19:51 · 452 阅读 · 0 评论 -
Lighting System Design UVA - 11400 (LIS /DP)
题目链接:点击打开链接You are given the task to design a lighting system for a huge conference hall. After doing a lot ofcalculation and sketching, you have figured out the requirements for an energy-efficient原创 2017-03-14 20:55:02 · 472 阅读 · 0 评论 -
Partitioning by Palindromes UVA - 11584 (LIS/DP)
点下看看能不能打开:https://vjudge.net/problem/34398/origin题目大意:输入小写字母字符串,然后分割成尽量少的回文串,例如:recacer本身就是回文串,fastcar只能分成7个,aaadbccb最少为3个为:aaa d bccbps:紫书p275 ps:记得以前做过关于回文串的dp,那个是比较复杂的了,属于区间dp的。对于这个题的话,要原创 2017-03-14 21:16:43 · 317 阅读 · 0 评论