【循环数组的最大字串和】Maximal sum Subsequence PROBLEM 题目描述 给一个 N×N 的矩阵 M,可以取连续的一段数(必须是横着或者竖着或者斜着,这个矩阵是循环的,具体如下)。要求找到一个子序列,使得这个序列的和最大。 对于 N=8 的矩阵,如下序列都是合法的: ? M2 ...
分类:
编程语言 时间:
2019-01-15 00:47:19
阅读次数:
175
题目链接:Lucky Subsequence 题意:只含有数字4和7的为幸运数字,对于一个长为 n 的序列,问有多少个长度为 k 的子序列(可以不用连续)中不包含两个相同的幸运数字,非幸运数字可以出现任意多次。 题解:因为序列中的数字小于等于 10^9 ,所以最多会有 2^10=1024 个不同的幸 ...
分类:
其他好文 时间:
2019-01-13 19:37:17
阅读次数:
164
题目描述: 样例: 数据范围与约定: 标签:平衡树,DP 考虑DP:令$dp(i,j)$表示前$i$个点选$j$个,能得到的最大价值。 得到转移方程:$dp(i,j)=\max\{dp(i 1,j),dp(i 1,j 1)+a_i\cdot j\}$ 这个方程很明显是$n^2$的。 经过打表/分析样 ...
分类:
其他好文 时间:
2019-01-12 23:00:26
阅读次数:
371
Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both sand t. t is pot ...
分类:
其他好文 时间:
2019-01-09 18:49:23
阅读次数:
188
Let's say we have two strings: str1 = 'ACDEB' str2 = 'AEBC' We need to find the longest common subsequence, which in this case should be 'AEB'. Using ...
分类:
其他好文 时间:
2019-01-01 23:51:59
阅读次数:
161
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The ...
分类:
其他好文 时间:
2019-01-01 17:17:58
阅读次数:
134
例1 , POJ3061:Subsequence Description A sequence of N positive integers (10 < N < 100 000), each of them less than or equal 10000, and a positive integ ...
分类:
其他好文 时间:
2018-12-23 12:00:55
阅读次数:
138
Common Subsequence http://poj.org/problem?id=1458 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 63836 Accepted: 26653 Description A subse ...
分类:
其他好文 时间:
2018-12-10 11:41:25
阅读次数:
193
// O(nlogn) class Solution { public: int lengthOfLIS(vector& nums) { int n = nums.size(); if (n dp; dp.push_back(nums[0]); for (int i = 1; i & nums) {... ...
分类:
其他好文 时间:
2018-12-08 15:43:09
阅读次数:
164