Bellovin Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Submission(s): Problem Description Peter has a sequence a1,a2,...,an and he define a function on the sequence -- F(a1,a2,...,an)=(f1,f2,...,fn), whe…
题目链接:https://vjudge.net/contest/148584#problem/A 题目大意: 解题思路:题目要求为:输出与已知序列的每一个元素的f(i)(f(i)的定义如题)相同的字典序最小的序列.稍微思考便知,其实就是叫我们求出原序列的f(i),这个很容易做到,只要在最长上升子序列的模板题上稍微做一些改动,记录下原序列每一个元素的f(i)即可.具体实现见代码. #include <bits/stdc++.h> using namespace std; ; int rise[N…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4681 题意: 给你a,b,c三个串,构造一个d串使得d是a,b的子序列,并且c是d的连续子串.求d最大的长度. 题解: 枚举a,b串开始匹配c的位置,(结束的位置可以贪心出来),然后前后都用最长公共子序列来跑就可以了. O(n^2)预处理,O(n^2)枚举. #pragma comment(linker, "/STACK:102400000,102400000") #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…
题意: 序列arr[i--n];输出以a[i]为结尾的最长上升子序列.1<=n<=100000; 思路: O(n*log(n)),求最长上升子序列. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int maxn = 100000+100; int arr[maxn]; int main ()…
题意:一个含有n个元素的数组,删去k个连续数后,最长上升子序列        /*思路参考GoZy 思路: 4 2 3 [5 7 8] 9 11 ,括号表示要删掉的数, 所以  最长上升子序列  =   ] 右边数A的lis + [左边最大值小于A的lis 即相当于枚举删除的所有情况,并求它们的LIS,取最大值 如本例 : 最长 = 2[ 9 11]  + 2[2 3],  然后将框从左往右移,算出最大值 用nlog(n)求LIS: 对于a[i],在arr数组中用log(n)找到比它小的数的个数…
Input The first line contains an integer T indicating the total number of test cases. Each test case starts with an integer n in one line, then one line with n integers a1,a2,…,an. 1≤T≤2000 2≤n≤105 1≤ai≤105 There are at most 20 test cases with n>1000…
Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 39661    Accepted Submission(s): 18228 Problem Description A subsequence of a given sequence is the given sequence with some el…
http://acm.split.hdu.edu.cn/showproblem.php?pid=1950 题意:求最长上升(不连续or连续)子序列 推荐博客链接: http://blog.csdn.net/sinat_30062549/article/details/47197073 #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include &l…
枚举每个位置,求以num[i]为起点的最长不下降子序列和以num[i]为结尾的最长不递增子序列. 并且把相同值的个数统计一下,最后要减去算重复了的. 比如: 1 9 4 4 2 2 2 3 3 3 7 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; + ; int n; int num[MAXN]; int stack1[MAXN]; int stack2[MA…