ACM - 其他DP
LP_Cong
Python, Qt C++ Developer ACMer https://github.com/Linzecong
展开
-
POJ - 3404 Bridge over a rough river (DP)
很有意思的一道题目,不知道是用了贪心的思想还是动态规划。我认为一开始是贪心的思考,然后找到最佳决策,然后再用dp的思想去实现,前面的i个人的最少时间,对后面肯定没有影响。首先对时间进行排序,一开始肯定是想让走得最快的人跟过去,这样回来的时候原创 2017-08-16 13:59:45 · 317 阅读 · 0 评论 -
CodeForces - 919D Substring (DP 记忆化搜索)
Substringtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a graph with n nodes and m directed原创 2018-02-01 00:29:28 · 279 阅读 · 0 评论 -
CodeForces - 918D MADMAX (DP 记忆化搜索)
MADMAXtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs we all know, Max is the best video game player amo原创 2018-01-31 17:28:28 · 330 阅读 · 0 评论 -
GYM - 101201B Buggy Robot(BFS+DP)
You are trying to program a robot to navigate through a 2-dimensional maze and find the exit.The maze can be represented as a grid with n rows and m columns. Some grid cells have obstaclesthat the rob原创 2017-10-02 21:49:26 · 873 阅读 · 0 评论 -
HDU - 6197 array array array (2017 ACM-ICPC 亚洲区 (沈阳赛区) 网络赛 1004)
array array arrayProblem DescriptionOne day, Kaitou Kiddo had stolen a priceless diamond ring. But detective Conan blocked Kiddo's path to escape from the museum. But Kiddo didn't want to gi原创 2017-09-10 22:48:20 · 818 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 H. Skiing
题意:有向图求最长路解题思路:DP求最长路,用到了Floyd的思想,把每一点的最长路都求一遍,记录最大即可#include#include#include#include#include#include#include#include#include#include#include#原创 2017-09-09 21:01:42 · 430 阅读 · 0 评论 -
2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 L. The Heaviest Non-decreasing Subsequence Problem
Let SS be a sequence of integers s_{1}s1, s_{2}s2, ......, s_{n}sn Each integer is is associated with a weight by the following rules:(1) If is is negative, then its weight is 00.(2)原创 2017-09-24 17:46:07 · 948 阅读 · 0 评论 -
HDU - 6170 Two strings
Two stringsProblem DescriptionGiving two strings and you should judge if they are matched.The first string contains lowercase letters and uppercase letters.The second string contains low原创 2017-08-22 21:06:20 · 546 阅读 · 5 评论 -
HDU - 1025 Constructing Roads In JGShining's Kingdom(最长单调子序列 nlogn)
解题思路:学习了nlogn的方法,怎么感觉比n^2的算法还要好理解……dp[i]存的是以i为最长上升子序列长度时,最后那个数的最小值。对于每一个数,我们只要找到dp数组里刚好比那个数大的那个数的位置,就是那个最长上升子序列的长度了,然后更新它的最小值。然后dp数组里存的肯定是有序上升的序列,因此可以采用二分查找。原创 2017-08-09 10:35:18 · 240 阅读 · 0 评论 -
POJ - 1065 Wooden Sticks(最长上升子序列)
这里用到了一个定理, 上升子序列最少划分数=倒着来一遍最长上升子序列。以后再深入研究这个定理,暂时记着。原创 2017-08-09 11:29:03 · 308 阅读 · 0 评论 -
POJ - 1952 BUY LOW, BUY LOWER(最长下降子序列,计数)
BUY LOW, BUY LOWERDescriptionThe advice to "buy low" is half the formula to success in the bovine stock market.To be considered a great investor you must also follow this problems' advice:原创 2017-08-09 15:19:28 · 374 阅读 · 1 评论 -
POJ - 1692 Crossed Matchings(DP)
解题思路:慢慢练,相信以后也可以自己想到递推式!!用dp[i][j]代表第一行第1~i个和第二行第1~j个之间的最多连接数。先不考虑将a[i],b[j]连线的情况,肯定有dp[i][j]=max(dp[i][j-1],max(dp[i-1][j],dp[i-1][j-1]));然后再考虑连线的情况。如果a[i]==a[j],那么将a[i]和b[j]连线是毫无意义的,因为不可能产生相交,所以要考虑不相等的情况,这个时候应该怎么办呢。这里用到了贪心的思想,将第二行与a[i]最近相等的相连,和第一行与b[j]最近原创 2017-08-09 16:14:10 · 264 阅读 · 0 评论 -
HDU - 2881 Jack's struggle (最长上升子序列变形)
Jack's struggleProblem DescriptionA team of airborne troops are ready to complete some missions.The battlefield was divided into a grid of n*n, this team can be air-dropped at any place on原创 2017-08-09 17:15:57 · 728 阅读 · 0 评论 -
2018年上海金马五校程序设计竞赛 Problem B : Ball Game
Problem B : Ball GameFrom: DHUOJ, 2018060902Submit (Out of Contest)Time Limit: 3 sDescriptionThere are 4 types of balls (A, B, C and D) and a huge box. The balls of the same type have the same weight....原创 2018-06-09 17:25:09 · 790 阅读 · 1 评论