F - City Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1505 Appoint description: Description Bob is a strategy game programming specialist. In his new city building game the gaming enviro…
题意:是二维的1506,即在1506的基础上,再加一个for循环,即从第一行到最后一行再扫一遍--- 自己写的时候,输入的方法不对---发现输不出结果,后来看了别人的----@_@发现是将字母和空格当成一个字符串来输入的. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int h[1010][1010],l[1010…
# include <stdio.h> # include <algorithm> # include <string.h> # include <iostream> using namespace std; char a[1010][1010]; int dd[1010][1010];///宽度 int r[1010],l[1010]; int main() { int t,i,j,n,m,max1; while(~scanf("%d"…
City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4531    Accepted Submission(s): 1919 Problem Description Bob is a strategy game programming specialist. In his new city building game t…
题目链接 题意 : 中文题不详述. 思路 : 二维背包,dp[i][h]表示当前忍耐值为i的情况下,杀了h个怪得到的最大经验值,状态转移方程: dp[i][h] = max(dp[i][h],dp[i-a[j].toler][h-1]+a[j].exper) ; #include <stdio.h> #include <string.h> #include <iostream> using namespace std ; struct node { int exper…
HDU 1024  Max Sum Plus Plus // dp[i][j] = max(dp[i][j-1], dp[i-1][t]) + num[j] // pre[j-1] 存放dp[i-1][t] 里的 (1<=t<=j-1)最大值. //dp[j] = max(dp[j-1], pre[j-1]) + num[j]; #include <stdio.h> #include <string.h> #include <iostream> #defin…
//#pragma comment(linker, "/STACK:102400000,102400000") /** 题目:hdu6078 Wavel Sequence 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6078 题意:给定a序列和b序列.从a中取一个子序列x(数的位置顺序保持不变),子序列每个数满足a1<a2>a3<a4>a5<a6... 波浪形 从b中取相同长度的子序列y,也满足波浪形. 如果x…
http://acm.hdu.edu.cn/showproblem.php?pid=2888 题意:给出一个n*m的矩阵,还有q个询问,对于每个询问有一对(x1,y1)和(x2,y2),求这个子矩阵中的最大值,和判断四个角有没有等于这个最大值的. 思路:二维RMQ模板题.注意内存卡的挺紧的. #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using nam…
<传送门> 滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 74477   Accepted: 27574 Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道载一个区域中最长底滑坡.区域由一个二维数组给出.数组的每个数字代表点的高度.下面是一个例子 1  2  3 …
题目链接:https://codeforces.com/contest/1245/problem/F 题意:给定一个区间(L,R),a.b两个数都是属于区间内的数,求满足 a + b = a ^ b 的实数对个数. 题解:看到求区间内满足一定条件的数的个数,应该用数位dp,数位dp基本操作是编写出solve函数调用记忆化搜索,那么考虑solve(R,R)是求0到R满足条件的答案,solve(L-1,R)求a属于0到L-1,b属于0到R满足条件的答案,solve(L-1,L-1)是ab都属于0到L…
题目描述也没啥好说的,就是给你个你n*n的矩形(带权),求其中最大权值的子矩阵. 首先比较好想的就是二维前缀和,n<=120,所以可以用暴力. 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,f[130][130],ans=-0x3f3f3f3f; 4 //n^4爆搜 5 int main(){ 6 scanf("%d",&n); 7 for(int i=1;i<=n;i++) 8 for…
之前只知道这个东西的大概概念,没具体去写,最近呵呵,今补上. 二维线段树 -- 点更段查 #include <cstdio> #include <cstring> #include <iostream> using namespace std; int N,M; double ma[110<<2][1010<<2]; void pushUpY(int xu,int u){ ma[xu][u]=max(ma[xu][u<<1], ma[…
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3594 [题意] 给定一个n个数的序列,有K次将一个区间内的数加1的机会,问最长不下降子序列. [思路] 首先知道每次加1一个区间为[i,n]肯定不会差. 设f[i][j]为前i个数,还有j次机会的LIS,则有转移式: f[i][j] = max{ f[a][b],h[a]+b<=h[i]+j } 则可以用二维BIT加速方程转移. [代码] #include<set> #inc…
题目链接 题意 : 给你每个柿子树的位置,给你已知长宽的矩形,让这个矩形包含最多的柿子树.输出数目 思路 :数据不是很大,暴力一下就行,也可以用二维树状数组来做. #include <stdio.h> #include <string.h> #include <iostream> using namespace std ; ][] ; int main() { int N ,S,T ,W,H; while(scanf("%d",&N) !=…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 148003    Accepted Submission(s): 35976 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
Division Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 999999/400000 K (Java/Others) Total Submission(s): 3984    Accepted Submission(s): 1527 Problem Description Little D is really interested in the theorem of sets recently. There’s a pro…
Problem Description Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,factories and buildings. There is still some space i…
/* dp[i][j]=max(dp[i][j-1]+a[j],max(dp[i-1][k])+a[j]) (0<k<j) dp[i][j-1]+a[j]表示的是前j-1分成i组,第j个必须放在前一组里面. max( dp[i-1][k] ) + a[j] )表示的前(0<k<j)分成i-1组,第j个单独分成一组. */ #include <iostream> #include <cstdio> #include <cstring> #inclu…
---恢复内容开始--- Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13003    Accepted Submission(s): 6843 Problem Description A group of researchers are designing an experiment to te…
洛谷P1855 榨取kkksc03 分析:套路是很明显的01背包,但是这时受约束的变量有两个了,这种情况下就该用多维背包了 分析方法一样的,用dp[i][j][k]表示从前i个愿望中挑选总时间和总金钱不超过j,k时的最大愿望数. 则状态转移方程应该为:dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j-tme[i]][k-mny[i]]+1). 因为多维数组,虽然这题数据量小,但是能用滚动数组就尽量用吧. 上代码: #include<bits/stdc++.h> u…
http://codeforces.com/gym/101257/problem/C 询问从左上角走到右下角,每次只能向右或者向左,捡起三种物品算作一个logo,求最多能得到多少个logo. 设dp[i][j][k][h]表示走到(i, j)这个格子,然后得到的第一种物品是k,第二种物品是h的时候,能得到的第三个物品的最大值是多少. -inf表示不存在这个状态,其实第三种物品可以算出来,因为一共的步数就是i + j - 1,所以捡起的物品数量是固定的. 所以直接这样dp下去即可,是一个背包问题.…
第一种做法是贪心做法,只要前面的数比后面的大就把他删掉,这种做法是正确的,也比较好理解,这里就不说了,我比较想说一下ST算法,RMQ的应用 主要是返回数组的下标,RMQ要改成<=(这里是个坑点,取连续数是可以的),他的转移方程为x = dp[i-1][j],y = dp[i-1][j+1<<(i-1)]; dp[i][j] = a[x] <= a[y] ? x : y; 这里既是转化为取n-m个数,首先在1 ~ m+1中必然选一个数,所以这个数就是n-m数中第一个数,记录所选的位置…
D. Make The Fence Great Again time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a fence consisting of nn vertical boards. The width of each board is 11. The height of the ii-th boar…
这题是上一题的升级版 关键在于条形图的构造,逐行处理输入的矩阵,遇到'F'则在上一次的条形图基础上再加1,遇到'R'则置为0 然后用上一题的算法,求每行对应条形图的最大矩阵的面积. 另外:本来是debug都不用就1A的节奏.可在输入数据上,一开始我用的是scanf读入字符 和 getchar跳过无效字符,在测试数据上是没有问题的,但一交上去就WA掉了. 看到别人的代码使用cin读入的.其实,如果输入数据不太大的话,cin还是比较放心好用的. //#define LOCAL #include <i…
思路: 树套树,先维护x树,再维护y树,多练练应该就能懂了 代码: #include<cstdio> #include<cmath> #include<cstring> #include<iostream> #include<algorithm> #define ll long long using namespace std; const int N = 300+5; double node[205<<2][1005<<…
1218: [HNOI2003]激光炸弹 题目:传送门 题解: 一道经典题目啊... 为了更好的操作...把整个坐标系向右上角移动,从(1,1)开始 那么f[i][j]统计一下以(i,j)作为右上角,以(1,1)作为左下角所组成的矩阵里面的价值和 不难发现,爆炸范围为R*R,且刚好在边上的点不会被摧毁,那么有效矩阵的四条边上肯定就只有R个点 那么ans=max(ans,f[i][j]+f[i-r][j-r]-f[i][j-r]-f[i-r][j]); 代码: #include<cstdio>…
D. Vanya and Treasure time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Vanya is in the palace that can be represented as a grid n × m. Each room contains a single chest, an the room locat…
[题目]D. Animals and Puzzle [题意]给定n*m的01矩阵,Q次询问某个子矩阵内的最大正方形全1子矩阵边长.n,m<=1000,Q<=10^6. [算法]动态规划DP+二维ST表 [题解]设f[i][j]为以(i,j)为右下角的最大正方形全1子矩阵. f[i][j]=min{ f[i-1][j-1] , f[i][j-1] , f[i-1][j] }+1 然后用二维ST表处理f[i][j]的子矩阵最小值. 对于每次询问,二分边长x,答案即子矩阵(x1+x-1,y1+x-1…
题目: ​ 思路: 二维dp,完全背包,状态转移方程dp[i][z] = max(dp[i][z], dp[i-1][z-a[j]]+b[j]),dp[i][z]表示在杀i个怪,消耗z个容忍度的情况下获得的最大的经验值. 刚看到这个题一直把思维限制在一维dp中,总是不能表达全部的条件,然后想到二维dp.因为目的是升级,所以dp表示的就要是最大的经验,下标自然就是剩下的条件忍耐度和杀怪的个数了.理清了这些,却死在设计程序上,,,,,,,,,终归是dp做的太少了. 代码: #include <ios…
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…