摘要: 采用的是 O(nlogn)的算法。算法的关键是: 用一个数组g[i] 记录当前有i个元素的递增子序列的最后一个元素的最小值,因为g是单调的,所以可以用二分.Longest Ordered SubsequenceTime Limit:2000MSMemory Limit:65536KTotal Submissions:25957Accepted:11274DescriptionA numeric sequence ofaiis ordered ifa1<a2< ... <aN. Let the subsequence of the given numeric sequence 阅读全文
posted @ 2013-03-24 21:56 chenhuan001 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 求一个串需要添加多少个字符才能变成回文。思路: 求出这个串与他的反串的最大公共子序列, 其实这个序列就是最大的已存在的回文数。 然后用总的数量减之即可PalindromeTime Limit:3000MSMemory Limit:65536KTotal Submissions:45849Accepted:15630DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are 阅读全文
posted @ 2013-03-24 17:16 chenhuan001 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 入门题。有条件控制的状态转移 if(s[i]==j[i]) dp[i][j]=dp[i-1][j-1]+1;else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);Common SubsequenceTime Limit:1000MSMemory Limit:10000KTotal Submissions:31866Accepted:12457DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. G. 阅读全文
posted @ 2013-03-24 13:30 chenhuan001 阅读(200) 评论(0) 推荐(0) 编辑