HDu 2830 Matrix Swapping II(dp)】的更多相关文章

Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find some rectangles in the matrix whose entries are all 1, and we define the maximum area of such rectangle as this matrix's goodness. We can swap any two columns any…
题意: N*M的矩阵,每个格中不是0就是1. 可以任意交换某两列.最后得到一个新矩阵. 问可以得到的最大的子矩形面积是多少(这个子矩形必须全是1). 思路: 先统计,a[i][j]记录从第i行第j列格往上连续的0的个数. 枚举每一行作为答案子矩阵的底, 然后将这一行的a[i][j]从大到小排序,扫一遍计算. 看代码. 代码: int n,m; char temps[1005][1005]; int a[1005][1005]; int ts[1005]; bool cmp(int a,int b…
Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1430    Accepted Submission(s): 950 Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find som…
题目链接 Problem Description The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't matter,I will give you a link: Here is the l…
http://acm.hdu.edu.cn/showproblem.php?pid=2830 题意:-- 思路:对于每一列,它是固定的,用dp[][]处理出连续的长度.例如: 假设我们扫第四列的时候,我们可以知道 i = 4,j = 1这个位置是4,那么它上面是有3个连续的1,因此它的面积可以是4 * 1, i = 4, j = 2的时候,因为刚才左边肯定大于等于现在的值,那么目前的面积可以是3 * 2,以此类推. 图: 1 1 0 0         DP数组:  1 1 0 0      …
给一个矩阵,依然是求满足条件的最大子矩阵 不过题目中说任意两列可以交换,这是对题目的简化 求出h数组以后直接排序,然后找出(col-j)*h[j]的最大值即可(这里的j是从0开始) 因为排序会影响到h数组下一行的求解,所以将h数组中的元素复制到temp数组中去,再排序 //#define LOCAL #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> us…
Matrix Swapping II Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1543    Accepted Submission(s): 1036 Problem Description Given an N * M matrix with each entry equal to 0 or 1. We can find so…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1864 题目: 最大报销额 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 25248    Accepted Submission(s): 7771 Problem Description 现有一笔经费可以报销一定额度的发票.允许报销的发票类…
守护雅典娜 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 324    Accepted Submission(s): 91 Problem Description 许多塔防游戏都是以经典的“守护雅典娜”为原型的.玩家需要建立各种防御工具来阻止怪物接近我们的女神——雅典娜. 这里,我们可以建造的防御工具只有标准圆形状的防御墙,建立在雅典…
有n(2e4)个宝石两个人轮流从左侧取宝石,Alice先手,首轮取1个或2个宝石,如果上一轮取了k个宝石,则这一轮只能取k或k+1个宝石.一旦不能再取宝石就结束.双方都希望自己拿到的宝石数比对方尽可能多.问你,先手比后手多拿的最大宝石数. dp[s][k] 表示从已经拿了s个,这一次可以拿k个,也可以拿k+1个. 那么dp[s][k] 表示 已经拿了s个,这一次可以拿k个或k+1个的最大差值. #include <cstdio> #include <cstdlib> #includ…