POJ 2533 最小上升子序列】的更多相关文章

D - POJ 2533 经典DP-最长上升子序列 A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N. Fo…
作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subsequence 最长递增子序列 使用$len[i]$表示序列中所有长度为$i$的递增子序列中最小的第$i$个数的值为$len[i]$.对于序列的第j个数$arr[j]$,在$len$中二分查找,找到最后一个小于$arr[j]$的数$len[k]$,如果$len[k]$是序列$len$中最后的一个数,那…
17-单调递增最长子序列 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:21 submit:49 题目描述: 求一个字符串的最长递增子序列的长度 如:dabdbf最长递增子序列就是abdf,长度为4 输入描述: 第一行一个整数0<n<20,表示有n个字符串要处理 随后的n行,每行有一个字符串,该字符串的长度不会超过10000 输出描述: 输出字符串的最长递增子序列的长度 样例输入: 复制 3 aaa ababc abklmncdefg 样例输…
Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 47465   Accepted: 21120 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ...…
#include "stdio.h" #include "stdlib.h" #define random(x) (rand()%x) void creat_array(int a[],int len,int max); void print_array(int a[],int n); void main(){ printf("please input two numbers as the array's length and the array's ma…
1.链接地址: http://poj.org/problem?id=2533 http://bailian.openjudge.cn/practice/2757 2.题目: 总Time Limit: 2000ms Memory Limit: 65536kB Description 一个数的序列bi,当b1 < b2 < ... < bS的时候,我们称这个序列是上升的.对于给定的一个序列(a1, a2, ..., aN),我们可以得到一些上升的子序列(ai1, ai2, ..., aiK)…
题目链接:http://poj.org/problem?id=2533 Time Limit: 2000MS Memory Limit: 65536K Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ...,…
d.最长上升子序列 s.注意是严格递增 c.O(nlogn) #include<iostream> #include<stdio.h> using namespace std; ; int a[MAXN],b[MAXN]; //b[k]是序列a中所有长度为k的递增子序列中的最小结尾元素值 //用二分查找的方法找到一个位置,使得num>b[i-1]并且num<b[i],并用num代替b[i] int Search(int num,int low,int high){ in…
Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N. For example, seq…
题意:最长上升子序列nlogn写法 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ]; ]; int main(){ int n; while(cin>>n){ ;i<n;i++){ cin>>a[i]; } memset(dp,,sizeof(dp)); dp[]=a[]; ; ;i&…
Longest Ordered Subsequence A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N.…
两种算法 1.  O(n^2) #include<iostream> #include<cstdio> #include<cstring> using namespace std; ]; ]; int main() { int n, maxn; while(scanf("%d", &n) != EOF) { maxn = ; ; i < n; i++) { scanf("%d", &a[i]); dp[i]…
Longest Ordered Subsequence 搬中文 Descriptions: 给出一个序列,求出这个序列的最长上升子序列. 序列A的上升子序列B定义如下: B为A的子序列 B为严格递增序列 Input 第一行包含一个整数n,表示给出序列的元素个数. 第二行包含n个整数,代表这个序列. 1 <= N <= 1000 Output 输出给出序列的最长子序列的长度. Sample Input 7 1 7 3 5 9 4 8 Sample Output 4 题目链接: https://v…
传送门 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i1 < i2 < ... < iK <= N. For example, s…
Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 38980   Accepted: 17119 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ...…
#include<iostream> using namespace std ; ; int f[N]; int a[N]; int n; int main() { cin>>n; ; i<=n; i++) cin>>a[i]; ; i<=n; i++) { f[i]=; ; j<=i; j++) { if(a[j]<a[i]) { f[i]=max(f[i],f[j]+); } } } ; ; i<=n; i++) res=max(res…
Title: http://poj.org/problem?id=2533 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i1 < i2 < .…
题目:http://poj.org/problem?id=2533 题意:最长上升子序列.... 以前做过,课本上的思想 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { ]; ],i,j,n; int nmax; cin>>n; ; i<=n; i++) { cin>&…
题目链接:http://poj.org/problem?id=2533 思路分析:该问题为经典的最长递增子序列问题,使用动态规划就可以解决: 1)状态定义:假设序列为A[0, 1, .., n],则定义状态dp[i]为以在所有的递增子序列中以A[i]为递增子序列的最后一个数字的所有递增子序列中的最大长度: 如:根据题目,在所有的以3结尾的递增子序列有[3]和[1, 3],所以dp[2] =2; 2)状态转移方程:因为当A[j] < A[i]时(0<= j < i),dp[i] = Max…
链接:http://poj.org/problem?id=2533 题解 #include<iostream> using namespace std; ]; //存放数列 ]; //b[i]表示以a[i]为结尾的子序列的最大长度 int main(){ int n; scanf("%d",&n); ;i<n;i++) scanf("%d",&a[i]); dp[]=; ;i<n;i++){ ;j<i;j++) //对于…
题目链接:http://poj.org/problem?id=1509 题意:给定一个字符串,求一个起点使字符串从该起点起的字符串字典序最小[题目的字符串起点从1开始] 思路:最小表示法模板题 #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include…
Repairing Company Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 6646   Accepted: 1788 Description Lily runs a repairing company that services the Q blocks in the city. One day the company receives M repair tasks, the ith of which occu…
题目链接:http://poj.org/problem?id=3422 思路:求从起点到终点走k次获得的最大值,最小费用最大流的应用:将点权转化为边权,需要拆点,边容量为1,费用为该点的点权,表示该点的权值只能获取一次,另外,应该连一条容量为inf,费用为0的边,因为每条边都可以走多次.另外就是增加源点和汇点了,源点与起点连容量为k,费用为0的边,表示可以走k次,同理终点与汇点也如此.然后就是求最大费用了,这与求最小费用类似,只需将spfa函数稍作修改即可. #include<iostream>…
题目链接:http://poj.org/problem?id=3308 思路:裸的最小点权覆盖,建立超级源点和超级汇点,将源点与行相连,容量为这行消灭敌人的代价,将列与汇点相连,容量为这列消灭敌人的代价,对于每一个敌人(x,y),连边x->y,容量为inf,这样就说明选取的点覆盖了那些边(敌人),然后跑最大流求最小割即可. PS:这里是乘积最小,要取对数转化为和最小. #include<iostream> #include<cstdio> #include<cstrin…
传送门: http://poj.org/problem?id=2533 Longest Ordered Subsequence Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 61731   Accepted: 27632 Description A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the…
题目链接:http://poj.org/problem?id=2125 思路:将最小点权覆盖转化为最小割模型,于是拆点建图,将点i拆成i,i+n,其中vs与i相连,边容量为w[i]-,i+n与vt相连,边容量为w[i]+,如果i,j有边相连,则i与j+n连边inf.从而跑最大流求解.对于输出解决放案,我们可以在残余网络中进行dfs,从vs出发,对于那些i<=n没有遍历到的点,说明被取走了,输出‘-’,对于那些i>n遍历到的点,说明之前有j->i的边(j<=n),vs->j不是…
题目链接:http://poj.org/problem?id=1548 思路:最小路径覆盖是很容易想到的(本题就是求最小的路径条数覆盖所有的点),关键是如何建图,其实也不难想到,对于当前点,如果后面的点它能够到达,那么就连边. 最小路径覆盖=顶点数-最大匹配. http://paste.ubuntu.com/5939379/…
题目链接:http://poj.org/problem?id=3164 详细可以看这里:http://www.cnblogs.com/vongang/archive/2012/07/18/2596851.html 我没怎么看懂 = =,姑且做个模板了.. 题意就是给n个点,m条单向边,并且已知根节点,求有向图的最小生成树. #include <stdio.h> #include <iostream> #include <string.h> #include <al…
Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7491   Accepted: 2172 Description Ikki is the king of a small country – Phoenix, Phoenix is so small that there is only one city that is responsible fo…
Given strings S and T, find the minimum (contiguous) substring W of S, so that T is a subsequenceof W. If there is no such window in S that covers all characters in T, return the empty string "". If there are multiple such minimum-length windows…