ZOJ 1108 & HDU 1160 - FatMouse's Speed】的更多相关文章

题目大意:给你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): 14980    Accepted Submission(s): 6618 Special Judge Problem Description FatMouse believes that the fatter a mouse is, the faster…
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…
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): 24573    Accepted Submission(s): 10896Special 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 进行递增排序,如…
http://acm.hdu.edu.cn/showproblem.php?pid=1160 同样是先按它的体重由小到大排,相同就按speed排就行. 这样做的好处是,能用O(n^2)枚举,因为前面的肯定不能和后面的搭配了. 然后就是LIS的题了, #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #defin…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1160 给你一些老鼠的体重和速度,问你最多需要几只可以证明体重越重速度越慢,并输出任意一组答案. 结构体按照体重从小到大排序,然后根据速度就是最长下降子序列. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #includ…
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…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1160 题意 给出一系列的 wi si 要找出一个最长的子序列 满足 wi 是按照升序排列的 si 是按照 降序排列的 思路 因为有双关键词 我们 可以先将一关键词 比如 W 按照 升序排序 再根据 S 关键词 来找 最长下降子序列 就可以了 要输出 其中的一个子序列 我们只要 记录 其 父节点就可以 再循环网上找 AC代码 #include <cstdio> #include <cstrin…