
ACM_经典DP
文章平均质量分 76
深海沧澜夜未央
这个作者很懒,什么都没留下…
展开
-
Super Jumping! Jumping! Jumping!
Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to yo原创 2017-04-26 19:54:37 · 327 阅读 · 0 评论 -
HDU 1159 Common Subsequence 最长公共子序列
Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exi原创 2017-04-25 22:57:33 · 281 阅读 · 0 评论 -
POJ 2250 Compromise(文章的最长公共子序列LCS)
In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is not a trivial task for the countries (maybe except原创 2017-12-27 09:58:36 · 221 阅读 · 0 评论 -
HDU1503 Advanced Fruits (最长公共子序列)
The company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn't work, but sometime原创 2017-12-27 10:03:21 · 387 阅读 · 0 评论 -
HDU 1579 记忆化搜索(水题)
We all love recursion! Don't we? Consider a three-parameter recursive function w(a, b, c): if a if a > 20 or b > 20 or c > 20, then w(a, b, c) returns: w(20, 20, 20) if a w(a, b, c-1)原创 2017-12-27 15:03:56 · 262 阅读 · 0 评论 -
2018年全国多校算法寒假训练营练习比赛(第二场) A 吐泡泡(模拟)
小鱼儿吐泡泡,嘟嘟嘟冒出来。小鱼儿会吐出两种泡泡:大泡泡"O",小泡泡"o"。两个相邻的小泡泡会融成一个大泡泡,两个相邻的大泡泡会爆掉。(是的你没看错,小气泡和大气泡不会产生任何变化的,原因我也不知道。)例如:ooOOoooO经过一段时间以后会变成oO。输入描述:数据有多组,处理到文件结束。每组输入包含一行仅有'O'与'o'组成的字符串。输出描述:每组输出仅包含一行,输出一行字符串代表小鱼原创 2018-01-30 10:35:04 · 549 阅读 · 0 评论 -
PAT L2-014. 列车调度 最长上升子序列
火车站的列车调度铁轨的结构如下图所示。两端分别是一条入口(Entrance)轨道和一条出口(Exit)轨道,它们之间有N条平行的轨道。每趟列车从入口可以选择任意一条轨道进入,最后从出口离开。在图中有9趟列车,在入口处按照{8,4,2,5,3,9,1,6,7}的顺序排队等待进入。如果要求它们必须按序号递减的顺序从出口离开,则至少需要多少条平行铁轨用于调度?输入格式:输入第一行给出一个整数N (2 &...原创 2018-03-24 10:10:08 · 258 阅读 · 0 评论 -
第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛 D psd面试
掌握未来命运的女神 psd 师兄在拿了朝田诗乃的 buff 后决定去实习。埃森哲公司注册成立于爱尔兰,是一家全球领先的专业服务公司,为客户提供战略、咨询、数字、技术和运营服务及解决方案。他们立足商业与技术的前沿,业务涵盖40多个行业,以及企业日常运营部门的各个职能。凭借独特的业内经验与专业技能,以及翘楚全球的交付网络,他们帮助客户提升绩效,并为利益相关方持续创造价值。埃森哲是《财富》全球500强企...原创 2018-03-25 23:29:20 · 181 阅读 · 0 评论 -
第18届浙江大学校赛 F Schrödinger's Knapsack (DP)
DreamGrid has a magical knapsack with a size capacity of called the Schrödinger's knapsack (or S-knapsack for short) and two types of magical items called the Schrödinger's items (or S-items for shor...原创 2018-04-10 10:04:15 · 438 阅读 · 0 评论 -
新疆大学ACM-ICPC程序设计竞赛五月月赛(同步赛) C勤奋的杨老师
杨老师认为他的学习能力曲线是一个拱形。勤奋的他根据时间的先后顺序罗列了一个学习清单,共有n个知识点。但是清单中的知识并不是一定要学习的,可以在不改变先后顺序的情况下有选择的进行学习,而每一个知识点都对应一个难度值。杨老师希望,后学习的知识点的难度一定不低于前一个知识点的难度(i<j时ai<=aj),而可能存在一个临界点,在临界点以后,他希望后学习的知识点的难度一定不高于前一个知识点的难...原创 2018-05-02 11:04:02 · 289 阅读 · 0 评论 -
AtCoder Regular Contest 098 C - Attention DP思想,寻找相邻关系
Problem StatementThere are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the w...原创 2018-05-26 21:28:47 · 443 阅读 · 0 评论 -
AtCoder Regular Contest 098 D - Xor Sum 2 区间异或=相加 DP思想
Problem StatementThere is an integer sequence A of length N.Find the number of the pairs of integers l and r (1≤l≤r≤N) that satisfy the following condition:Al xor Al+1 xor … xor Ar=Al + Al+1 + … + ArH...原创 2018-05-27 13:33:18 · 793 阅读 · 0 评论 -
HDU 1025 最长不下降子序列nlogn算法
题意:最长不下降子序列思路:n*n的算法肯定超时,所以nlogn的写法(dp+二分)dp数组存的是当前最长的最长不下降子序列,数组内保证递增,因此可以二分找下一个数字需要插入的位置注意输出格式,road和roads区别,还有要输出两个换行#include #include #include #include using namespace std;#define N 5001原创 2017-12-26 15:46:28 · 408 阅读 · 0 评论 -
最长上升子序列 POJ 2533(n*n与 nlogn)
A 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...原创 2017-08-20 17:21:03 · 272 阅读 · 0 评论 -
Minimal Subarray Length
You are given an integer sequence of length N and another value X. You have to find a contiguoussubsequence of the given sequence such that the sum is greater or equal to X. And you have to findth原创 2017-04-30 16:34:17 · 719 阅读 · 0 评论 -
HDU 6024 Building Shops DP 提升
问题描述HDU的n个教室在一条线上,可以被认为是数字线。每个教室都有一个坐标。现在,小Q想在这些n个教室里建几个糖果店。总成本由两部分组成。在教室里建一个糖果店我会有一些成本ci。对于没有任何糖果店的每个教室P,P和左边一个糖果店的最右边的教室之间的距离也将包含在成本中。显然,如果没有糖果店的教室,左侧必须有一个糖果店。现在,小Q想以最低的成本知道如何建造糖果店。请写一原创 2017-05-09 15:15:15 · 946 阅读 · 0 评论 -
HDU 1081 DP找最大和的矩阵
Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of原创 2017-08-21 16:31:12 · 185 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 The Heaviest Non-decreasing Subsequence Problem
题意:给出一个序列S,每个数字都有自己的权值,si10000,权值为5,且si=si-10000,其他情况si为1,求最大和上升子序列。思路:如果直接求最大和上升子序列,题目那么就被麻烦化了,仔细观察,权值为1或5的只有正数,且是最大上升子序列,那么肯定是从正数作为第一位开始的,将权值5的这个数字变化为5个权值1的一样数字,然后题目就转换成了求最大上升子序列的长度#include #in原创 2017-11-07 20:26:05 · 185 阅读 · 0 评论 -
种草莓 HNUST 1714(求正方形边长 DP)
题目描述小美有一块N*N的正方形菜地,寒暑交替,冬去春来,现在到了可以种植草莓的季节了。遗憾的是,有些格子已经种上别的蔬菜了。小美希望在菜地中找到最大的一块正方形空地来种草莓,以满足她大吃草莓的愿望。输入第一行是一个整数T(1每一组测试数据的格式如下:(1)第一行是一个正整数N(2(2)随后有N行,每行有N个字符。字符只有两种可能,'E'表示空置,'F'表示已经种上原创 2017-12-08 00:26:37 · 523 阅读 · 0 评论 -
CodeForces 429B Working out(dp,四个角递推)
Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represent原创 2017-08-23 14:34:37 · 274 阅读 · 0 评论 -
数塔 HDU 2084 (二维方格DP )
Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1原创 2017-04-25 23:06:27 · 395 阅读 · 0 评论 -
Max Sum 最大连续和的子序列 HDU 1003 (一维序列DP)
Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 +原创 2017-04-25 23:02:27 · 360 阅读 · 0 评论 -
To the Max POJ 1050(一维序列的变形)
Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of原创 2017-12-26 08:43:12 · 1576 阅读 · 3 评论 -
HDU 1257 最少拦截系统(最长上升子序列+贪心)
roblem Description某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救原创 2017-08-21 14:41:15 · 292 阅读 · 0 评论 -
福州大学第十五届程序设计竞赛 D - 给力的移动 FZU - 2287 最长连续子序列 O(n)
你的弟弟给你安排了一个任务,他给了你1到N个数字的乱序排列,现在你想给你的弟弟秀一波操作,操作最少的次数把序列变成1到N的顺序排列,每次操作你可以选择序列中的一个数字并把它移动到序列的头部或尾部。Input包含多组测试数据。每组测试数据的第一行为正整数N,表示排列的长度。第二行为N个数字的乱序排列。n≤100000Output输出最少的操作次数Sample Input66 3 2 4 5 1Sam...原创 2018-06-05 10:07:44 · 289 阅读 · 0 评论