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…
传送门:Problem 1020 https://www.cnblogs.com/violet-acmer/p/9852294.html 讲解此题前,先谈谈何为最长上升子序列,以及求法: 一.相关概念 1.串 & 子序列 一个串的子串是指该串的一个连续的局部. 如果不要求连续,则可称为它的子序列. 比如对串: "abcdefg" 而言,"ab","abd","bdef" 等都是它的子序列. 特别地,一个串本身,以及空串…
Palindrome Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 53414   Accepted: 18449 Description A 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…
题目链接 题意:有好多行,每行两个数字,代表大象的体重和智商,求大象体重越来越大,智商越来越低的最长序列,并输出. 思路:先排一下序,再按照最长上升子序列计算就行. 还有注意输入, 刚开始我是这样输入的   cnt = 1; while(~scanf("%d%d", &p[cnt].w, &p[cnt++].s)) 结果p[1].w的值没有,为0, 所以注意在连续输入的时候不能用 cnt++; #include <iostream> #include <…
//Accepted 4372 KB 140 ms //dp 最长上升子序列 nlogn #include <cstdio> #include <cstring> #include <iostream> using namespace std; ; int dp[imax_n]; int d[imax_n]; int a[imax_n]; int n; int len; int max(int a,int b) { return a>b?a:b; } int bi…
DP——最长上升子序列(LIS) 基本定义: 一个序列中最长的单调递增的子序列,字符子序列指的是字符串中不一定连续但先后顺序一致的n个字符,即可以去掉字符串中的部分字符,但不可改变其前后顺序. LIS长度的求解方法: 1.$N^2$递推 动态规划一般的思考方式就是考虑将一个大问题分解成若干个小问题来求解,而小问题之间又有共同的求解方法, 或考虑当前状态与哪一个状态有关,并考虑如何转移. 那来思考以第$i$个数字为结尾的LIS是由哪一个转移过来的,显然肯定是由$1...i-1$转移过来的 每次都向…
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','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…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1503 题意:给出两个字符串 要求输出包含两个字符串的所有字母的最短序列.注意输出的顺序不能变.//意会一下吧,我说不清=.= 思路:最长公共子序列的变形,需要记录位置.直接看代码应该就可以懂,不是很难. click here:http://www.cnblogs.com/a-clown/p/5918080.html  //hdu1159 最长公共子序列裸题. 代码: #include<i…
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…