
动态规划DP
文章平均质量分 57
永夜莫明
菜是原罪
展开
-
Hedwig's Ladder
Hedwig the hamster enjoys exploring networks of hamster tubes. Each day, Hedwig’s ownerrearranges the tubes to form a new network of tubes.One day, Hedwig awoke to find that the network of tubes had...原创 2018-12-08 20:08:20 · 473 阅读 · 0 评论 -
配对(贪心+dp,好题)
https://cn.vjudge.net/problem/HYSBZ-1237你有n 个整数Ai和n 个整数Bi。你需要把它们配对,即每个Ai恰好对应一 个Bp[i]。要求所有配对的整数差的绝对值之和尽量小,但不允许两个相同的数配 对。例如A={5,6,8},B={5,7,8},则最优配对方案是5配8, 6配5, 8配7,配对整数 的差的绝对值分别为2, 2, 1,和为5。注意,5配5,6配...原创 2019-07-17 21:21:55 · 768 阅读 · 0 评论 -
Queries for Number of Palindromes(回文串,dp,好题)
https://cn.vjudge.net/problem/CodeForces-245HYou've got a strings = s1s2...s|s|of length|s|, consisting of lowercase English letters. There also areqqueries, each query is described by two int...原创 2019-07-17 22:57:53 · 372 阅读 · 0 评论 -
String painter(区间dp,好题难题)
https://cn.vjudge.net/problem/HDU-2476There are two strings A and B with equal length. Both strings are made up of lower case letters. Now you have a powerful string painter. With the help of the pa...原创 2019-07-18 00:56:16 · 878 阅读 · 0 评论 -
2019hdu多校第一场A题Blank(dp,时空优化)
http://acm.hdu.edu.cn/showproblem.php?pid=6578题目描述There are N blanks arranged in a row. The blanks are numbered 1,2,…,N from left to right.Tom is filling each blank with one number in {0,1,2,3}. ...原创 2019-07-25 01:14:01 · 386 阅读 · 0 评论 -
Mathematical Curse(线性dp)
问题 B: Mathematical Curse问题 B: Mathematical Curse时间限制: 1 Sec内存限制: 128 MB提交: 152解决: 35[提交] [状态] [命题人:admin]题目描述A prince of the Science Continent was imprisoned in a castle because of hi...原创 2019-08-02 19:26:16 · 161 阅读 · 0 评论 -
Combine String (字符串匹配,dp)
https://cn.vjudge.net/problem/HDU-5707Given three stringsaa,bbandcc, your mission is to check whetherccis the combine string ofaaandbb.A stringccis said to be the combine string ofaaa...原创 2019-07-22 10:20:39 · 468 阅读 · 0 评论 -
Hurdles of 110m(简单dp)
https://cn.vjudge.net/problem/ZOJ-2972In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China and Beijing Olympics is to be a festival for people ...原创 2019-07-22 10:46:17 · 268 阅读 · 0 评论 -
被3整除的子序列(线性dp)
链接:https://ac.nowcoder.com/acm/problem/21302?&headNav=acm来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述给你一个长度为50的数字串,问你有多少个子序列构成的数字可以被3整除答案对1e9+7取模...原创 2019-08-04 00:18:13 · 230 阅读 · 1 评论 -
删括号(判定性dp)
链接:https://ac.nowcoder.com/acm/problem/21303?&headNav=acm来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述给你一个合法的括号序列s1,每次你可以删除一个"()"你可以删除0个或者多个"()"求能...原创 2019-08-04 01:29:26 · 1273 阅读 · 0 评论 -
牛牛与数组(简单dp+优化)
链接:https://ac.nowcoder.com/acm/problem/21738来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述牛牛喜欢这样的数组:1:长度为n2:每一个数都在1到k之间3:对于任意连续的两个数A,B,A<=B 与(A % B !=...原创 2019-08-04 02:05:58 · 349 阅读 · 0 评论 -
牛牛数括号(dp)
链接:https://ac.nowcoder.com/acm/problem/21652来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K64bit IO Format: %lld题目描述牛牛最近开始学括号匹配拉给你两个括号序列,不保证合法,求有多少种不同的方法可以将两个括号序列合并成一个合法的括号序列合并的时...原创 2019-08-04 22:07:01 · 421 阅读 · 2 评论 -
Snowy Smile(线段树维护子矩阵最大值/降维打击维护子矩阵最大值(TLE))
http://acm.hdu.edu.cn/showproblem.php?pid=6638问题 E: Snowy Smile时间限制: 4 Sec内存限制: 128 MB提交: 54解决: 9[提交] [状态] [命题人:admin]题目描述There are n pirate chests buried in Byteland, labeled by 1,2,…...原创 2019-08-08 01:10:04 · 371 阅读 · 0 评论 -
回文子序列计数(dp)
链接:https://ac.nowcoder.com/acm/problem/21587来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述我们称正着读与反着读一样的串为回文串,比如abba与racecar都是回文串我们称长度为奇数的回文为奇回文,中间的字符称为回...原创 2019-08-08 01:44:16 · 1603 阅读 · 1 评论 -
codeforces(dp/01背包)
链接:https://ac.nowcoder.com/acm/problem/21314来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述牛牛正在打一场CF比赛时间为T分钟,有N道题,可以在比赛时间内的任意时间提交代码第i道题的分数为maxPoints[i],...原创 2019-08-08 02:09:31 · 383 阅读 · 0 评论 -
美丽序列(暴力dp)
链接:https://ac.nowcoder.com/acm/problem/21313来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述牛牛喜欢整数序列,他认为一个序列美丽的定义是1:每个数都在0到40之间2:每个数都小于等于之前的数的平均值具体地说:fo...原创 2019-08-05 20:27:47 · 742 阅读 · 0 评论 -
博丽灵梦的小游戏(dp+快读)
题目描述萃香是一个极其喜欢喝⑨酒的鬼,有着操控密度的能力。某天,在博丽神社举行的夏日大宴会上,萃香被灵梦请去玩一个游戏。萃香需要操控一个在n行m列的方格的左上角(1,1)的气团,让这个气团最后行进到右下角(n,m)。萃香可以在每一格控制这个气团的密度。由于一些黑幕神奇的原因,可以认为这个气团的密度只有“高”和“低”两种,并且气团只能向右或向下移动。这个方格也不是一个什么一般的方格。在这里...原创 2019-08-09 21:45:19 · 1341 阅读 · 0 评论 -
PACKING(背包+O2/O3氧化)
问题 K: PACKING问题 K: PACKING时间限制: 1 Sec内存限制: 128 MB提交: 233解决: 19[提交] [状态] [命题人:admin]题目描述It was bound to happen. Modernisation has reached the North Pole. Faced with escalating costs...原创 2019-08-09 22:15:58 · 387 阅读 · 4 评论 -
The Staircases(dp,好题)
https://cn.vjudge.net/problem/ZOJ-1163One curious child has a set of N little bricks. From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly d...原创 2019-07-17 16:00:03 · 173 阅读 · 0 评论 -
ABBA(组合数学/dp)
链接:https://ac.nowcoder.com/acm/contest/881/E来源:牛客网Bobo has a string of length 2(n + m) which consists of characters `A` and `B`. The string also has a fascinating property: it can be decomposed i...原创 2019-07-19 14:15:21 · 629 阅读 · 2 评论 -
Max Sum Plus Plus (DP有点难)
Now I think you have got an AC in Ignatius.L’s “Max Sum” problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem.Given ...原创 2018-12-13 20:55:52 · 304 阅读 · 0 评论 -
Minimax (预处理)(枚举)
You are given a grid consisting of n rows each of which is dived into m columns. The rows are numbered from 1 to n from top to bottom, and the columns are numbered from 1 to m from left to right. Each...原创 2018-12-16 15:37:22 · 294 阅读 · 0 评论 -
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-12-10 18:45:06 · 294 阅读 · 0 评论 -
Constructing Roads In JGShining's Kingdom(思维+NlogN求最长上升子序列)(好题)
JGShining’s kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these cities are rich in resource (we call them rich cities) while the other...原创 2018-12-11 17:38:50 · 241 阅读 · 0 评论 -
Dollars (离线dp)
Problem问题New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and 5c coins. Write a program that will determine, for any given amount, in how many ways that a...原创 2018-12-11 20:55:26 · 577 阅读 · 0 评论 -
怪盗基德的挑战书 (kmp+dp)
在树最美丽的那天,当时间老人再次把大钟平均分开时,我会降临在灯火之城的金字塔前,带走那最珍贵的笑容。”这是怪盗基德盗取巴黎卢浮宫的《蒙娜丽莎的微笑》这幅画时,挑战书上的内容。 但这次,怪盗基德的挑战书上出现了一串串小写字母“aaab sdfeeddd...”。柯南以小学生的眼睛,超凡高中生的头脑,快速统计各种字母频率,字符串长度,并结合挑战书出现的时间等信息,试图分析怪盗基德的意图。最...原创 2019-02-17 16:07:59 · 671 阅读 · 0 评论 -
垒骰子 ( 矩阵快速幂 )
赌圣atm晚年迷恋上了垒骰子,就是把骰子一个垒在另一个上边,不能歪歪扭扭,要垒成方柱体。经过长期观察,atm 发现了稳定骰子的奥秘:有些数字的面贴着会互相排斥! 我们先来规范一下骰子:1 的对面是 4,2 的对面是 5,3 的对面是 6。假设有 m 组互斥现象,每组中的那两个数字的面紧贴在一起,骰子就不能稳定的垒起来。 atm想计算一下有多少种不同的可能的垒骰子方式。两种垒骰子方式相...原创 2019-03-01 23:41:10 · 864 阅读 · 0 评论 -
Schrödinger's Knapsack(贪心+DP)
题目链接:https://cn.vjudge.net/problem/ZOJ-4019DreamGrid has a magical knapsack with a size capacity ofcalled the Schrödinger's knapsack (or S-knapsack for short) and two types of magical items called...转载 2019-03-03 11:30:55 · 264 阅读 · 0 评论 -
Seam Carving(阅读理解+dp+记录路径)
Fish likes to take photo with his friends. Several days ago, he found that some pictures of him were damaged. The trouble is that there are some seams across the pictures. So he tried to repair these ...原创 2019-03-16 11:41:28 · 517 阅读 · 0 评论 -
格子刷油漆(dp)
格子刷油漆 X国的一段古城墙的顶端可以看成 2*N个格子组成的矩形(如图1所示),现需要把这些格子刷上保护漆。 你可以从任意一个格子刷起,刷完一格,可以移动到和它相邻的格子(对角相邻也算数),但不能移动到较远的格子(因为油漆未干不能踩!) 比如:a d b c e f 就是合格的刷漆顺序。 c e f d a b 是另一种合适的方案。 当已知 N ...原创 2019-04-05 17:00:38 · 348 阅读 · 0 评论 -
DNA比对
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=5e3+5;short int dp[N][N];char a[N],b[N];int main(){ int T; scanf("%d",&T); while(T-...原创 2019-05-19 21:10:35 · 2228 阅读 · 0 评论 -
Sum(线性筛+dp)
题目链接https://nanti.jisuanke.com/t/A1956题目大意:就是找一个数拆成两个无平方因子的组合数,然后求个前缀和。分析:0.如果一个数是质数,毫无疑问ans[i]=2;1.如果一个数某个质因子的指数大于等于3,那么无论怎么分,至少有一边的数里面含有平方因子,所以ans[i]=0;2.如果一个数k的某个质因子p的指数是1,这个1要么给...原创 2019-06-28 14:42:50 · 208 阅读 · 0 评论 -
wyh的考核(dp/容斥原理)
链接:https://ac.nowcoder.com/acm/problem/15442来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述wyh非常喜欢lol游戏,一天,他听说学校要选拔lol队员,他非常高兴的就去了,选拔规则是,一共有N个评委,每个评委根据线上对线...原创 2019-06-29 18:09:18 · 420 阅读 · 0 评论 -
最少拦截系统 (最长上升子序列)
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统....原创 2019-07-16 19:18:59 · 221 阅读 · 0 评论 -
免费馅饼 (dp)
https://cn.vjudge.net/problem/HDU-1176都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平...原创 2019-07-16 19:57:39 · 221 阅读 · 0 评论 -
Subarray(思维+模拟+lazy标记+……)
https://ac.nowcoder.com/acm/contest/882/J当时开局ac率100%,然后就死磕这道题(主要是因为题目短,不想去读别的题),一发RE,一发MLE,然后放弃了……WJYTXDY当时的想法很朴素,就是对于每一个位置的前缀和,看在他左边比他小的前缀和的数量(很明显时间复杂度不行,k*1e9,当时抱着如果评测机跑的快的话,说不定……),因为有负数,所以加...原创 2019-07-23 21:21:55 · 184 阅读 · 0 评论 -
Find the Marble(线性dp/概率dp)
https://cn.vjudge.net/problem/ZOJ-3605Alice and Bob are playing a game. This game is played with several identical pots and one marble. When the game starts, Alice puts the pots in one line and puts...原创 2019-07-16 22:45:45 · 182 阅读 · 0 评论 -
2019百度之星初赛第二场 度度熊与组题
https://vjudge.net/problem/HDU-6677沃老师在出比赛的题目时遇到麻烦啦!遇到的麻烦如下:现在沃老师手上有 2n 道题,题目编号由 1∼2n ,已知第 i 道题难度为 ai ,这些题的难度还满足当 i<j 时 ai≤aj 。现在沃老师想把这些题目分在两套比赛上,每套比赛会被分到 n 道题,每道题都会恰出现在其中一场比赛中。假设分配完后,第一套题难度第 i...原创 2019-08-19 23:45:48 · 806 阅读 · 0 评论