http://acm.hdu.edu.cn/showproblem.php?pid=3966
Problem Description
Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies...
分类:
其他好文 时间:
2015-05-28 10:56:38
阅读次数:
145
// 10635 Prince and Princess LCS 变 lIS
// 本意求LCS,但是规模有60000多,复杂度肯定不够
// 注意如果俩个序列的值的范围相同,那么可以在一个
// 串中记录在另外一个串中的位置。这样就可以转化成
// 最长上升子序列的问题啦,复杂度是nlogn,可以ac
// 这题,还是挺有考究的价值的,很不错
// 哎,继续练吧。。。。。
#include...
分类:
其他好文 时间:
2015-05-19 20:57:34
阅读次数:
104
题目:在一个n*n的棋盘上,格子标号1~n*n,现在有两个人从1跳到n*n(不走重复点),
现在要求去掉最少的中间点,使得路径是一样的。
分析:dp,LIS,LCS。问题是求最大公共子序列,数据较大需要O(nlgn)算法。
发现题目中的数据是不重复的,所以可以转化成最大上升子序列;
记录序列1中每个元素对应的顺序,将序...
分类:
其他好文 时间:
2015-05-13 23:13:48
阅读次数:
192
Aragorn's StoryTime Limit: 20 SecMemory Limit: 256 MB题目连接http://codevs.cn/problem/1060/DescriptionOur protagonist is the handsome human prince Aragorn...
分类:
其他好文 时间:
2015-05-12 15:15:08
阅读次数:
133
Problem DescriptionOur protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who w...
分类:
其他好文 时间:
2015-05-10 22:14:21
阅读次数:
141
题意:王子和公主同时从1出发走到 n*n, 求他们两个路径的最长公共子序列;
思路:因为这题n有250,如果用LCS负责度为O(n^2),容易超时,于是我们选择它的优化版Lis算法来求最长公共子序列,这样我们的复杂度就降为O(n*logn)了。
Lis算法:
先回顾经典的O(n^2)的动态规划算法,设A[t]表示序列中的第t个数,F[t]表示从1到t这一段中以t结尾的最长上升子序列...
分类:
其他好文 时间:
2015-05-07 22:09:29
阅读次数:
161
Prince and PrincessTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1267Accepted Submission(s): 358...
分类:
其他好文 时间:
2015-05-07 18:43:49
阅读次数:
119
题目传送:UVA - 10635
思路:直接思路是两个串的LCS,不过这个题可以转化为LIS,因为说了序列中各个元素互不相同,所以可以来个映射算出第二个字符串中的字符对应第一个字符串中字符的位置(不存在即删去),然后算出这些位置的LIS即可
AC代码:
#include
#include
#include
#include
#include
#include
#i...
分类:
其他好文 时间:
2015-05-04 15:35:09
阅读次数:
107
uva 10635 Prince and Princess(DP)
In an n x n chessboard, Prince and Princess plays a game. The squares in the chessboard are numbered
1, 2, 3 ... n*n, as shown below:
Prince stands i...
分类:
其他好文 时间:
2015-04-26 09:30:41
阅读次数:
130
The Prince George's County Fire Department said the guard was taken to hospital in a critical condition.The FBI said the shooting was related to anoth...
分类:
其他好文 时间:
2015-04-10 11:18:45
阅读次数:
126