题目大意:给你一个序列,你可以翻转任意一段子序列一次,求最长不下降子序列长度 tips:子序列可以不连续,但不能破坏在原序列中的顺序 观察数据范围,n<=50,很小,考虑dfs *dfs来跑区间dp可以巧妙的解决区间两端元素的置换问题 记忆化搜索,f[i][j][l][r] 代表对于区间[i,j],构成最长不下降子序列的元素值域在[l,r]时,最长不下降子序列的长度 注意特判端点 #include <bits/stdc++.h> #define N 55 #define inf 0x3f…
题目描述 Farmer John is arranging his NN cows in a line to take a photo (1 \leq N \leq 501≤N≤50). The height of the iith cow in sequence is a(i)a(i), and Farmer John thinks it would make for an aesthetically pleasing photo if the cow lineup has a large i…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2089 题意: 给你两个数作为一个闭区间的端点,求出该区间中不包含数字4和62的数的个数 思路: 数位dp中的 dfs 记忆化搜索方法解. 模板: int dfs(int i, int s, bool e) { ) return s==target_s; ) return f[i][s]; ; ; :; d <= u; ++d) res += dfs(i-, new_s(s, d), e&&d…
C.Coolest Ski Route 题意:n个点,m条边组成的有向图,求任意两点之间的最长路径 dfs记忆化搜索 #include<iostream> #include<string.h> #include<string> #include<algorithm> #include<math.h> #include<string> #include<string.h> #include<vector> #in…
pid=1078">FatMouse and Cheese Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4811    Accepted Submission(s): 1945 Problem Description FatMouse has stored some cheese in a city. The city can…
题意:容易理解... 思路:我开始是用dfs剪枝做的,968ms险过的,后来在网上学习了记忆化搜索=深搜形式+dp思想,时间复杂度大大降低,我个人理解,就是从某一个点出发,前面的点是由后面的点求出的,然后一直递归先求出后面的点,最后达到求解的效果. 代码实现: #include<iostream> #include<string.h> #include<stdio.h> using namespace std; ][],count[][]; int n,k; ][]={…
Problem H Game Show Math Input: standard input Output: standard output Time Limit: 15 seconds A game show in Britain has a segment where it gives its contestants a sequence of positive numbers and a target number. The contestant must make a mathemati…
8636 跳格子 该题有题解 时间限制:2457MS  内存限制:1000K提交次数:139 通过次数:46 题型: 编程题   语言: G++;GCC Description 地上有一个n*m 的数字格子,每个格子有一个坐标(i,j)(其中1<=i<=n , 1<=j<=m),规定左上角为(0,0), 右下角为(n,m),你要从最左端的一列的任意位置开始跳到最右边格子外. 下面两条你跳的时候的约束规则: 一.因为你的力气有限,每次只能跳一定的距离.给定一个k 为你的弹跳力,则从(…
emmmmm,我还是看了题解的....尴尬,其实不用记忆化搜索也是可以的.因为我不用也是最后一个点超时.但是我是用的贪心+DFS...超时的原因是贪心....mmp,本来加贪心就是为了不超时.... 思路: 搜索树的构建:就是把这一层的点把所有未访问的点当成孩子,这就构成了搜索树! 记忆化: 就是把每个点的计算只是算一次,用个大表格记起来...尴尬 #include<iostream> #include<algorithm> #include<cmath> #inclu…
Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道载一个区域中最长底滑坡.区域由一个二维数组给出.数组的每个数字代表点的高度.下面是一个例子 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小.在上面的例子…