题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1503 题意:给出两个字符串 要求输出包含两个字符串的所有字母的最短序列.注意输出的顺序不能变.//意会一下吧,我说不清=.= 思路:最长公共子序列的变形,需要记录位置.直接看代码应该就可以懂,不是很难. click here:http://www.cnblogs.com/a-clown/p/5918080.html  //hdu1159 最长公共子序列裸题. 代码: #include<i…
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard output: standard The most prestigious sports club in one city has exactly N members. Each of its members is strong and beautiful. More precisely, i-t…
A person wants to travel around some places. The welfare in his company can cover some of the airfare cost. In order to control cost, the company requires that he must submit the plane tickets in time order and the amount of the each submittal must b…
题意: 输入俩个字符串,怎样变换使其所有字符对和最大.(字符只有'A','C','G','T','-') 其中每对字符对应的值如下: 怎样配使和最大呢. 比如: A G T G A T G -  G T T A -  G 和为 (-3)+5+5+(-2)+5+(-1) +5=14. 题解: 最长公共子序列的变形. 设dp[i][j]为a的前i个和b的前j个字符能构成的最大和. score[][]为每对字符的值,比如score['A']['G']为'A','G'这对字符对应的值. string a…
题目链接 题意:有好多行,每行两个数字,代表大象的体重和智商,求大象体重越来越大,智商越来越低的最长序列,并输出. 思路:先排一下序,再按照最长上升子序列计算就行. 还有注意输入, 刚开始我是这样输入的   cnt = 1; while(~scanf("%d%d", &p[cnt].w, &p[cnt++].s)) 结果p[1].w的值没有,为0, 所以注意在连续输入的时候不能用 cnt++; #include <iostream> #include <…
Description 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 for Luxembourg). To enforce that Germa…
Alignment Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13319   Accepted: 4282 Description In 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 cap…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1243 分析:dp[i][j]表示前i个子弹去炸前j个恐怖分子得到的最大分.其实就是最长公共子序列加每个字母值为1,这里每个字母代表的值变化了一下. 状态转移方程:if(s1[i-1]==s2[j-1])dp[nxt][j]=dp[cur][j-1]+val[s1[i-1]];                              else  dp[nxt][j]=max(dp[nxt][j-1]…
题目大意:输入数据直到文件结束,每行两个数据 体重M 和 速度V,将其排列得到一个序列,要求为:体重越大 速度越低(相等则不符合条件).求这种序列最长的长度,并输出路径.答案不唯一,输出任意一种就好了. 题目思路:这是个最长上升子序列的问题,我们按W的升序进行排序,若W相等则按V的降序排序.用Pre[]记录当前点的前驱节点,Last记录序列最后一个点,maxn记录最长长度,完成动规后可根据Last和Pre[]输出路径. #include<cstdio> #include<stdio.h&…
传送门:Problem 1020 https://www.cnblogs.com/violet-acmer/p/9852294.html 讲解此题前,先谈谈何为最长上升子序列,以及求法: 一.相关概念 1.串 & 子序列 一个串的子串是指该串的一个连续的局部. 如果不要求连续,则可称为它的子序列. 比如对串: "abcdefg" 而言,"ab","abd","bdef" 等都是它的子序列. 特别地,一个串本身,以及空串…