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. python 基础 4.3 高阶函数下和匿名函数

    一 .匿名函数 顾名思议就是没有名字的函数,那为什么要设立匿名函数,他有什么作用呢?lambda 函数就是一种快速定义单行的最小函数,可以用在任何需要函数的地方.   常规版: def fun(x,y ...

  2. EasyDSS流媒体视频实时回传与录像管理解决方案

    一.背景 1.1 方案背景 随着互联网基础设施建设的不断完善和发展,带宽的不断提速,尤其是光纤入户,4G/5G/NB-IoT各种技术的大规模商用,视频在各行各业越来越受到重视,无论是传统的视频媒体转向 ...

  3. 编译安装Heartbeat常见错误

    -----------那些需要升级包还有少包的错误就不写了---------- <b>1</b>. Reusable-Cluster-Components-glue-glue- ...

  4. Linux内核的编译安装

    前言 Linux内核是Linux操作2347系统的核心,也是整个Linux功能体现的核心,就如同发动机在汽车中的重要性.内核主要功能包括进程管理.内存管理.文件管理.设备管理.网络管理等.Linux内 ...

  5. 【题解】Jury Compromise(链表+DP)

    [题解]Jury Compromise(链表+DP) 传送门 题目大意 给你\(n\le 200\)个元素,一个元素有两个特征值,\(c_i\)和\(d_i\),\(c,d \in [0,20]\), ...

  6. winserver 资源下载

    http://msdn.itellyou.cn/  下载各种系统资源,支持迅雷下载,速度杠杠的

  7. 《转》使用nginx和php实时产生缩略图

    在做自动静态化的时候,突然想到下面这个场景,也给出了解决方法.亲,真的很实用,耐心看下去.     当我从后台上传一个截图之后,480*800的截图之后,当时就没有压缩出320*480的小缩略图.好吧 ...

  8. 蓝牙 CTS 测试

    安装蓝牙测试安装包 之后  . 安卓包名字 android-cts-6.0_r19-linux_x86-x86.zip 解压之后 /cts/android-cts/tools/  目录下 运行  ./ ...

  9. Java for LeetCode 105 Construct Binary Tree from Preorder and Inorder Traversal

    Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that ...

  10. delphi XE7 HttpEncode 编码问题

    近期在做网址编码相关的工作,发现在用 XE5 编译的时候,一切正常,拿 到 XE7下 就 结果错误了.百度了下,谷歌 了下,有人提出,但是,我没有找到答案,也许都没有碰到这个问题,也许都己经自己默默的 ...