Problem(A22):Party

Judge Info
Memory Limit: 32768KB
Case Time Limit: 10000MS
Time Limit: 10000MS
Judger: Number Only Judger

Description
Frog Frank is going to have a party, he needs a large empty rectangular place. He ranted a large rectangular place in the forest, unfortunately the place is not empty, there are some trees in it. For solving the problem, he makes a map of the rectangular place with m × n grid, he paint the grid to black if there are some trees in it. Now, all he needs to do is find the largest rectangular place in the map contains no black grid.

Task
Frank is asking your help to find out, the area(the number of grids) of the largest rectangular place without black grid.

Input
The first line of input contains , the number of test cases. For each test case, the first contains two integer number m and n , denotes the size of the map. In the next m lines, each line contains a string with n ’0’,’1’ characters, ’0’ denotes the empty grid, ’1’ denotes the black grid.

Output
For each test case, print the area(the number of grids) of the largest rectangular place in a line.

Sample Input
2
3 3
111
100
111
5 5
10101
00100
00000
00000
00001
Sample Output
2
12

分析:n,m最大值为10,总时间竟然给了10s!本来还担心时间问题,一看这规模完全不用了.
注:我把本题中01地位互换了一下.
设f[i][j]为第i行第j列左边有多少个连续的1(包括第j列)
对于某个f[i][j]如果f[i-1][j]>f[i][j],那不妨扩充一层,向下类似,直到f[x][j]>f[i][j]为止.这样我们就得到了一个由[i,j]张成的矩形.通过比较这n*m个矩形就可以得出最大面积了.

#include<stdio.h>
#include<string.h>
][];
][];
int main()
{
    int T;
    scanf("%d",&T);
    int n,m;
    while (T--)
    {
        scanf("%d%d",&n,&m);
        memset(f,,sizeof(f));
        int i,j,k;
        ;i<=n;i++) scanf("%s",s[i]);
        ;i<=n;i++)
            ;j<=m;j++)
                ]==;
                ;
        ;i<=n;i++)
            ;j<=m;j++)
                ) f[i][j]=f[i][j-]+;
        int Max=0,l,r;
        ;i<=n;i++)
            ;j<=m;j++)
            {
                ;k--)
                    ][j]<f[i][j])
                    {
                        l=k;
                        break;
                    }
                for (k=i;k<=n;k++)
                    ][j]<f[i][j])
                    {
                        r=k;
                        break;
                    }
                )>Max) Max=f[i][j]*(r-l+);
            }
        printf("%d\n",Max);
    }
    ;
}

SZU-A22的更多相关文章

  1. SZU:B47 Big Integer II

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

  2. SZU:D89 The Settlers of Catan

    Judge Info Memory Limit: 65536KB Case Time Limit: 3000MS Time Limit: 3000MS Judger: Number Only Judg ...

  3. SZU:B47 Big Integer I

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

  4. SZU:G32 Mass fraction

    Judge Info Memory Limit: 32768KB Case Time Limit: 5000MS Time Limit: 5000MS Judger: Float Numbers (1 ...

  5. SZU:J38 Number Base Conversion

    Judge Info Memory Limit: 32768KB Case Time Limit: 1000MS Time Limit: 1000MS Judger: Number Only Judg ...

  6. SZU:B54 Dual Palindromes

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Number Only Ju ...

  7. SZU:A66 Plastic Digits

    Description There is a company that makes plastic digits which are primarily put on the front door o ...

  8. SZU:G34 Love code

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

  9. SZU:A25 Favorite Number

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Number Only Ju ...

  10. SZU:A26 Anagram

    Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...

随机推荐

  1. CSS知识总结(八)

    CSS常用样式 8.变形样式 改变元素的大小,透明,旋转角度,扭曲度等. transform : none | <transform-function> <transform-fun ...

  2. Servlet编程

    Servlet编程 1. servlet概念及相关接口简介 java Servlet是运行在web服务器或应用服务器上的程序,他是作为来自web浏览器或其他HTTP客户端的请求和HTTP服务器山的数据 ...

  3. MySQL创建一个具有root权限的用户

    grant all privileges on *.* to 'user'@'host' identified by 'password' WITH GRANT OPTION MAX_QUERIES_ ...

  4. Xcode7编译打包后,iOS9设备无法打开http网址的问题

    在info.plist中添加一个节点: <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsAr ...

  5. Java攻城狮面试考题

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  6. Firefox上Web开发工具库一览

    Firefox的目标之一就是尽可能地使web开发者的生活更简单高效,并通过提供工具和具有很强扩展性的浏览器使人们创造出神奇的东西.使web开发者使用Firefox的时候,浏览器可以提供大量开发工具和选 ...

  7. webstorm激活码

    2016.2.3版本 43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0M0I0QTczWVlKIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZW ...

  8. Google https服务被屏蔽

    根据Google透明度报告显示,从上周(5月27日)开始,Google的部分服务开始被屏蔽,其中最主要的是HTTPS搜索服务和Google登录服务,所有版本的Google都受到影响,包括Google. ...

  9. clojure

    ide http://updatesite.ccw-ide.org/stable https://cursiveclojure.com/ http://web.clojurerepl.com/ htt ...

  10. 第22章 项目3:万能的XML

    Mix-in:混入类,是一种Python程序设计中的技术,作用是在运行期间动态改变类的基类或类的方法,从而使得类的表现可以发生变化.可以用在一个通用类接口中. 在实践一个解析XML文件的实践中,体会动 ...