given a 2-d matrix with 0 or 1 values

largest square of all 1's

dynamic programming, dp[i][j] = 1 + min{dp[i-1][j], dp[i][j-1], dp[i-1][j-1]} if m[i][j] == 1; otherwise a[i][j]=0;

largest submatrix of all 1's

https://leetcode.com/problems/maximal-rectangle/

dynamic programming. scan row-by-row and accumulate the "height" at each position; then for each accumulated row, run the "largest rectangle in histogram" algorithm.

query sum of submatrix
https://leetcode.com/problems/range-sum-query-2d-immutable/
similar to prefix-sum array, generate sum[i][j] = sum{mat[0..i][0..j]}, then it's straightforward to answer sum of all possible submatrixes.

largest sum of submatrix

column-wise (i, j) sum (i.e. sum columns[i..j]), then solve 1-D case in O(n), in total O(n^3)

submatrix的更多相关文章

  1. POJ3494Largest Submatrix of All 1’s[单调栈]

    Largest Submatrix of All 1’s Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 5883   Ac ...

  2. CF 375B Maximum Submatrix 2[预处理 计数排序]

    B. Maximum Submatrix 2 time limit per test 2 seconds memory limit per test 512 megabytes input stand ...

  3. [LintCode] Submatrix Sum 子矩阵之和

    Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return ...

  4. [CareerCup] 18.12 Largest Sum Submatrix 和最大的子矩阵

    18.12 Given an NxN matrix of positive and negative integers, write code to find the submatrix with t ...

  5. Codeforces Round #221 (Div. 1) B. Maximum Submatrix 2 dp排序

    B. Maximum Submatrix 2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...

  6. lintcode 中等题:Submatrix sum is 0 和为零的子矩阵

    和为零的子矩阵 给定一个整数矩阵,请找出一个子矩阵,使得其数字之和等于0.输出答案时,请返回左上数字和右下数字的坐标. 样例 给定矩阵 [ [1 ,5 ,7], [3 ,7 ,-8], [4 ,-8 ...

  7. Max Sub-matrix

    Max Sub-matrix 教练找的题目,目前样列过了 题意:找子矩阵的最大周长 思路:先离散每列,再枚举列(n*n),在当前枚举的两列之间求每行的和(n*n*n),但是开两个数组,一个包含两列上的 ...

  8. COJ 2105 submatrix

    submatrix 难度级别: A: 编程语言:不限:运行时间限制:2000ms: 运行空间限制:131072KB: 代码长度限制:102400B 试题描述   小A有一个N×M的矩阵,矩阵中1~N* ...

  9. Largest Submatrix(动态规划)

    Largest Submatrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  10. POJ-3494 Largest Submatrix of All 1’s (单调栈)

    Largest Submatrix of All 1’s Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 8551   Ac ...

随机推荐

  1. 各种jar包下方法的使用

    commons-codec-1.6.jar: DigestUtils.md5Hex(String str); httpclient-4.2.2.jar: HttpClient client=new D ...

  2. JSON中如何转义字符串中的双引号(转载)

    问: I'm trying to show double quotes but it shows one of the backslashes: "maingame": { &qu ...

  3. 怎么升级iOS10教程

    在前两天的开发者大会上刚推出了iOS10,我介绍一下怎么升级到iOS10的办法.所有人只用一个iPhone就可以升级到iOS10,不需要电脑,也不需要开发者账号. http://bbs.feng.co ...

  4. IC卡、ID卡、M1卡、射频卡的区别是什么【转】

    本文转载自:https://www.cnblogs.com/najifu-jason/p/4122741.html IC卡.ID卡.M1卡.射频卡都是我们常见的一种智能卡,但是很多的顾客还是不清楚IC ...

  5. LightOJ - 1079 Just another Robbery —— 概率、背包

    题目链接:https://vjudge.net/problem/LightOJ-1079 1079 - Just another Robbery    PDF (English) Statistics ...

  6. js/html/css做一个简单的图片自动(auto)轮播效果//带注释

    FF(firefox)/chrom/ie稳定暂无bug...注意:请自己建立一个images文件,放入几张900*238的图片(注意图片格式和名字与程序中一致). 1. [图片] 1.JPG 2. [ ...

  7. css3立体旋转菜单

    css3立体旋转菜单,css3,3D,立体旋转,立体菜单,菜单导航,css3立体旋转菜单是一款纯css3实现的三维立体旋转导航菜单. 源码下载页:http://www.huiyi8.com/sc/71 ...

  8. POJ 2976 Dropping tests:01分数规划【二分】

    题目链接:http://poj.org/problem?id=2976 题意: 共有n场考试,每场考试你得的分数为a[i],总分为b[i]. 你可以任意去掉k场考试. 问你最大的 100.0 * ( ...

  9. LightOJ 1132 Summing up Powers:矩阵快速幂 + 二项式定理

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1132 题意: 给定n.k,求(1K + 2K + 3K + ... + NK) % 2 ...

  10. IDT 信息设计工具使用

    IDT 大多使用于接外系统数据,也就是非SAP 系统数据库.虽然SAP BW 里有数仓概念,接外部系统的视图.集中在使用建模,query ,再通过BO来展示.可是有些我们需要直连数据库,取一两张表相对 ...