亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

SZU-A22

系統 1820 0

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>


        
          char
        
         s[
        
          15
        
        ][
        
          15
        
        
          ]; 
        
        
          int
        
         f[
        
          15
        
        ][
        
          15
        
        
          ]; 
        
        
          int
        
        
           main() { 
        
        
          int
        
        
           T; scanf(
        
        
          "
        
        
          %d
        
        
          "
        
        ,&
        
          T); 
        
        
          int
        
        
           n,m; 
        
        
          while
        
         (T--
        
          ) { scanf(
        
        
          "
        
        
          %d%d
        
        
          "
        
        ,&n,&
        
          m); memset(f,
        
        
          0
        
        ,
        
          sizeof
        
        
          (f)); 
        
        
          int
        
        
           i,j,k; 
        
        
          for
        
         (i=
        
          1
        
        ;i<=n;i++) scanf(
        
          "
        
        
          %s
        
        
          "
        
        
          ,s[i]); 
        
        
          for
        
         (i=
        
          1
        
        ;i<=n;i++
        
          ) 
        
        
          for
        
         (j=
        
          1
        
        ;j<=m;j++
        
          ) 
        
        
          if
        
         (s[i][j-
        
          1
        
        ]==
        
          '
        
        
          0
        
        
          '
        
        ) f[i][j]=
        
          1
        
        
          ; 
        
        
          else
        
         f[i][j]=
        
          0
        
        
          ; 
        
        
          for
        
         (i=
        
          1
        
        ;i<=n;i++
        
          ) 
        
        
          for
        
         (j=
        
          1
        
        ;j<=m;j++
        
          ) 
        
        
          if
        
         (f[i][j]==
        
          1
        
        ) f[i][j]=f[i][j-
        
          1
        
        ]+
        
          1
        
        
          ; 
        
        
          int
        
         Max=0,l,r
        
          ; 
        
        
          for
        
         (i=
        
          1
        
        ;i<=n;i++
        
          ) 
        
        
          for
        
         (j=
        
          1
        
        ;j<=m;j++
        
          ) { 
        
        
          for
        
         (k=i;k>=
        
          1
        
        ;k--
        
          ) 
        
        
          if
        
         (f[k-
        
          1
        
        ][j]<
        
          f[i][j]) { l
        
        =
        
          k; 
        
        
          break
        
        
          ; } 
        
        
          for
        
         (k=i;k<=n;k++
        
          ) 
        
        
          if
        
         (f[k+
        
          1
        
        ][j]<
        
          f[i][j]) { r
        
        =
        
          k; 
        
        
          break
        
        
          ; } 
        
        
          if
        
         (f[i][j]*(r-l+
        
          1
        
        )>Max) Max=f[i][j]*(r-l+
        
          1
        
        
          ); } printf(
        
        
          "
        
        
          %d\n
        
        
          "
        
        
          ,Max); } 
        
        
          return
        
        
          0
        
        
          ; }
        
      
    

?

SZU-A22


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 男女拍拍视频黄的全免费 | 羞羞的视频在线观看 | 国产日本亚洲欧美 | 日本老太做爰xx | 国产欧美亚洲另类第一页 | 青春禁区视频在线观看动漫版 | 欧美亚洲国产精品久久第一页 | 香港a毛片免费全部播放 | 视频一区二区国产 | 国产精品免费视频能看 | 天天草狠狠干 | 欧洲精品在线观看 | 国产日韩欧美亚洲综合首页 | 免费深夜视频 | julia紧身裙中文字幕在线看 | 亚洲综合爱爱久久网 | 国内在线观看 | 国产一级内谢a级高清毛片 国产一级片毛片 | 久久亚洲精品人成综合网 | 青青青爽线在线视频观看 | 99久久精品免费看国产一区二区 | 免费国产精成人品 | 国产精品视频永久免费播放 | 久久99精品麻豆国产 | 瑟瑟综合| 99久久国产免费福利 | 国产精品久久成人影院 | 在线综合视频 | aaaaaaa毛片| 久久精品视| 四虎永久免费影院在线 | 99精品国产在这里白浆 | 亚洲欧美韩日 | 天天干天天操天天舔 | 亚洲国产品综合人成综合网站 | 久久婷婷是五月综合色狠狠 | 日韩精品久久久毛片一区二区 | 99精品欧美一区二区三区 | 99热久久国产精品免费看 | 我要看一级毛片 | 国产高清免费午夜在线视频 |