#include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; struct node { int w, s; int index; //储存标号 } mouse[]; //小鼠的信息 //先体重,后速度 bool cmp(node a,node b) { if(a.w==b.w) return a.s<b.s; return a…
http://acm.hdu.edu.cn/showproblem.php?pid=1160 FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12338    Accepted Submission(s): 5405Special Judge Problem Description FatMouse be…
代码+题解: 1 //题意: 2 //输出在区间[li,ri]中有多少个数是满足这个要求的:这个数的最长递增序列长度等于k 3 //注意是最长序列,可不是子串.子序列是不用紧挨着的 4 // 5 //题解: 6 //很明显前面最长递增序列的长度会影响到后面判断,而且还要注意我们要采用哪种求最长递增序列的方式(一共有两种, 7 //一种复杂度为nlog(n),另一种是n^2),这里我才采用的是nlog(n)的. 8 // 9 //算法思想: 10 //定义d[k]: 11 //长度为k的上升子序列…
传送门: ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=108 HDU :http://acm.hdu.edu.cn/showproblem.php?pid=1160 题目大意: 输入好多组w 和 s 代表老鼠的重量和速度,要求找出满足 w 严格 升序, s严格降序的最大长度和他们的序号. 我是先排序,然后和ZOJ 1136 Longest Ordered Subsequence (http://blog.csdn.…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 56910    Accepted Submission(s): 26385 Problem Description Nowadays, a kind of chess game called “Super Jumping!…
求一个数列的最长上升序列 动态规划法:O(n^2) //DP int LIS(int a[], int n) { int DP[n]; int Cnt=-1; memset(DP, 0, sizeof(DP)); for(int i=0; i<n; i++ ) { for(int j=0; j<i; j++ ) { if( a[i]>a[j] ) { DP[i] = max(DP[i], DP[j]+1); Cnt = max(DP[i], Cnt);//记录最长序列所含元素的个数 }…
Description   A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be abl…
题意:第一列,给出老鼠的重量,第二列,给出老鼠的速度,要证明老鼠的重量越大,速度越小,给出最多老鼠的数量,并说明第几只. 思路:先将老鼠按照重量从大到小排序,然后速度是从小到大,求最长上升子序列,学习下怎么输出最长上升子序列的路径,输出最长上升子序列路径有很多种方法,这里面是记录每个数字在最长上升子序列中的下标.因为在维护最长上升子序列数组的时候,我们会遍历到每一个元素.代码里面有样例: //最长上升子序列输出路径 /* 1 7 3 5 2 记录在递增序列中的下标 逆序检索 1 2 2 3 2…
若干人左对齐站成最多5行,给定每行站多少个,列数从第一排开始往后递减.要求身高从每排从左到右递增(我将题意篡改了便于理解233),每列从前向后递增.每个人身高为1...n(n<=30)中的一个数(互不不同).求可行方案数.(地址点我qwq): 做了lyd书dp这一章的第一题,就不会qwq..果然菜的人还是永远菜啊,注定翻不了身. lyd的书上讲到了dp的方法,不是很理解.后来想通了,发现自己想的时候也想到了这一点转化,但是又很快把他抛弃掉了..冏. 上面所谓的转化就是说,我本来安排人去排列,是无…
#include <iostream> #include <algorithm> #include <string> #include <cstring> #include <cstdio> #define MAX 1005 using namespace std; int ans[MAX][MAX]; int main(){ string s1,s2; while(cin>>s1>>s2) { memset(ans,,s…
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24573    Accepted Submission(s): 10896Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster…
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14980    Accepted Submission(s): 6618 Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1160 题目意思:给出一堆老鼠,假设有 n 只(输入n条信息后Ctrl+Z).每只老鼠有对应的weight 和 speed.现在需要从这 n 只老鼠的序列中,找出最长的一条序列,满足老鼠的weight严格递增,speed严格递减. 我们可以用一个结构体来保存老鼠的信息,包括weight, speed 以及 id(这个 id 是未排序之前的,为了输出最后信息).那么首先对 weight 进行递增排序,如…
FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1160 Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on…
Problem Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are incre…
HDU - 1160 给一些老鼠的体重和速度 要求对老鼠进行重排列,并找出一个最长的子序列,体重严格递增,速度严格递减 并输出一种方案 原题等于定义一个偏序关系 $(a,b)<(c.d)$ 当且仅当 $a<c,b>d$ 然后找出最长链 ...我们就按照他说的重新排个序,然后找LIS吧,不过还需要去路径还原 数据量可以用$O(n^2)$的算法 不过我这里用来$O(nlogn)$的算法加上一个路径还原 嗯,其实是在一个单调栈上乱搞的二分罢了.... 最后要回溯一下并且记录答案才行 #incl…
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 20803    Accepted Submission(s): 9227Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster…
题意  输入n个老鼠的体重和速度   从里面找出最长的序列  是的重量递增时速度递减 简单的DP  令d[i]表示以第i个老鼠为所求序列最后一个时序列的长度  对与每一个老鼠i  遍历全部老鼠j  当(w[i] > w[j]) && (s[i] < s[j])时  有d[i]=max(d[i],d[j]+1)  输出路径记下最后一个递归即可了 #include<cstdio> #include<algorithm> using namespace std…
题目大意:给你n只老鼠的体重w和速度s,让你找出最长的子序列使得w[i] < w[j] 且 s[i] > s[j] (i < j).求最长序列的长度并输出该序列. LIS(Longest Increasing Subsequence)问题,先对老鼠进行排序,以w为第一关键字从小到大排序,再以s为第二关键字从大到小排序,然后就是LIS问题的处理了.LIS(i)表示以a[i]结尾的最长增长序列的长度. #include <cstdio> #include <algorith…
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13133    Accepted Submission(s): 5778Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster i…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1160 FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20100    Accepted Submission(s): 8909Special Judge Problem Description FatMou…
G - FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1160 Appoint description: Description FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1160 FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequen…
FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1160 Appoint description:  prayerhgq  (2015-07-28) System Crawler  (2015-09-05) Description FatMouse believes that the fatter a m…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1160 FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17386    Accepted Submission(s): 7694Special Judge Problem Description…
J. FatMouse's Speed FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence so that the weights are incre…
FatMouse's Speed Time Limit: 2 Seconds      Memory Limit:65536 KB     Special Judge FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of thi…
p的思路不一定要到最后去找到ans:也可以设置成在中间找到ans:比如J - FatMouse's Speed 这个题,如果要是让dp[n]成为最终答案的话,即到了i,最差的情况也是dp[i-1],就很难去保存路径,但是如果换一个思路,让dp[i]必须去参与,如果无法与前面的结合,那么就新开一个. 最后路径是保存的逆序的,那么开一个stack就可以解决. //显然这个题是要维护两个变量的最长上升子序列 #include <iostream> #include <fstream> #…
FatMouse's Speed Time Limit: 2 Seconds      Memory Limit:65536 KB     Special Judge FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of thi…
FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7213    Accepted Submission(s): 3181Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster it…