bzoj 3039 悬线法求最大01子矩阵
首先预处理每个F点左右,下一共有多少个F点,然后
对于每个为0的点(R),从这个点开始,一直到这个点
下面第一个R点,这一区间中的min(左),min(右)更新答案。
ps:我估计这道题数据有的格式不对,开始过不去,后来改了读入
就能过了
/**************************************************************
Problem:
User: BLADEVIL
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/
//By BLADEVIL
var
n, m :longint;
map :array[..,..] of longint;
ans, len1, len, len2 :longint;
left, right, down :array[..,..] of longint;
function max(a,b:longint):longint;
begin
if a>b then max:=a else max:=b;
end;
function min(a,b:longint):longint;
begin
if a>b then min:=b else min:=a;
end;
procedure init;
var
i, j, k :longint;
ss :ansistring;
begin
readln(n,m);
for i:= to n do
begin
readln(ss);
k:=;
for j:= to length(ss) do
if ss[j]<>' ' then
begin
inc(k);
if ss[j]='F' then map[i,k]:= else map[i,k]:=;
end;
end;
for i:= to n do
for j:= to m do
if map[i,j]= then left[i,j]:= else left[i,j]:=left[i,j-]+;
for i:=n downto do
for j:=m downto do
begin
if map[i,j]= then down[i,j]:= else down[i,j]:=down[i+,j]+;
if map[i,j]= then right[i,j]:= else right[i,j]:=right[i,j+]+;
end;
end;
procedure main;
var
i, j, k :longint;
begin
for i:= to n do
for j:= to m do
if map[i,j]= then
begin
len:=;
len1:=maxlongint div ;
len2:=maxlongint div ;
for k:= to down[i+,j] do
begin
len1:=min(len1,left[i+k,j]);
len2:=min(len2,right[i+k,j]);
ans:=max(ans,(len1+len2-)*k);
end;
if len1>=maxlongint div then continue;
inc(len,len1);
ans:=max(ans,(len-)*down[i+,j]);
end;
writeln(ans*);
end;
begin
init;
main;
end.
bzoj 3039 悬线法求最大01子矩阵的更多相关文章
- BZOJ 1057: [ZJOI2007]棋盘制作 悬线法求最大子矩阵+dp
1057: [ZJOI2007]棋盘制作 Description 国际象棋是世界上最古老的博弈游戏之一,和中国的围棋.象棋以及日本的将棋同享盛名.据说国际象棋起源于易经的思想,棋盘是一个8*8大小的黑 ...
- City Game UVALive - 3029(悬线法求最大子矩阵)
题意:多组数据(国外题好像都这样),每次n*m矩形,F表示空地,R表示障碍 求最大子矩阵(悬线法模板) 把每个格子向上延伸的空格看做一条悬线 以le[i][j],re[i][j],up[i][j]分别 ...
- hdu4328(经典dp用悬线法求最大子矩形)
http://wenku.baidu.com/view/728cd5126edb6f1aff001fbb.html 关于悬线法,这里面有详解. 我当时只想到了记录最大长度,却没有想到如果连最左边和最右 ...
- P4147 玉蟾宫(悬线法求最大子矩阵)
P4147 玉蟾宫 悬线法 ,\(l_{i,j},r_{i,j},up_{i,j}\) 分别表示 \((i,j)\) 这个点向左,右,上能到达的远点.然后面积就很好办了.具体实现见代码. 然而,还有更 ...
- bzoj 3039: 玉蟾宫 单调栈或者悬线法求最大子矩阵和
3039: 玉蟾宫 Time Limit: 2 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Description 有一天,小猫rainbow ...
- 【BZOJ-3039&1057】玉蟾宫&棋盘制作 悬线法
3039: 玉蟾宫 Time Limit: 2 Sec Memory Limit: 128 MBSubmit: 753 Solved: 444[Submit][Status][Discuss] D ...
- 2018.09.29 bzoj3885: Cow Rectangles(悬线法+二分)
传送门 对于第一个问题,直接用悬线法求出最大的子矩阵面积,然后对于每一个能得到最大面积的矩阵,我们用二分法去掉四周的空白部分来更新第二个答案. 代码: #include<bits/stdc++. ...
- 【BZOJ】3039: 玉蟾宫 悬线法
[题意]给定01矩阵,求最大全1子矩阵.n,m<=1000. [算法]动态规划(悬线法) [题解]★对于01矩阵中的任意一个全1极大子矩阵,都可以在其上边界遇到的障碍点处悬线到下边界的点x,则点 ...
- BZOJ 3039: 玉蟾宫( 悬线法 )
最大子矩阵...悬线法..时间复杂度O(nm) 悬线法就是记录一个H向上延伸的最大长度(悬线), L, R向左向右延伸的最大长度, 然后通过递推来得到. ----------------------- ...
随机推荐
- datagridview下拉框
下面介绍Winform中DataGridView的DataGridViewComboBoxColumn的使用方法: //首先获取数据源 //自己建立的静态数据源,你也可以从数据库读取 DataTabl ...
- CSS中的content和attr的用法
问题缘起 在闲看别人网站时发现了这样的代码 <span class="hamburger icon" data-icon="C"> .icon:be ...
- 如何将两个列表变成一个python字典
一个列表是 index = [0, 1, 2, 3, 4, 5, 6] 另一个是 day = ['1', '2', '3', '4', '5', '6', '7' ] 可以使用dict(zip(ind ...
- try 返回前执行fianlly
try catch finally 语句中 如果try中有返回语句,如果在fianlly代码块中有对这个值修改的话,并不影响其放回值 public class Test { public stati ...
- C# 判断是否为闰年的条件各是
//try 没增加异常数据处理 Console.WriteLine("根据输入的信息计算当年某个月份的天数,以及当年是否是闰年或平年,\n并判断2月份特殊月份的天数."); Con ...
- 生产WCF客户端类文件的命令格式
生产WCF客户端类文件的命令格式: svcutil.exe net.tcp://127.0.0.1:8732/ChromaMI.Remote.ConfigService/RemoteConfigSer ...
- 命令行工具cmder
1.下载地址 http://bliker.github.io/cmder/ 分为两个版本:mini版和Full版 2.快捷命令配置: 比如,快速启动canssandra/redis数据库服务和查询工具 ...
- UVA 10970 第一次比赛 D题 (后面才补的)
Mohammad has recently visited Switzerland. As heloves his friends very much, he decided to buy somec ...
- CodeForces 569A 第八次比赛 C题
Description Little Lesha loves listening to music via his smartphone. But the smartphone doesn't hav ...
- bc命令
bc 命令: bc 命令是用于命令行计算器. 它类似基本的计算器. 使用这个计算器可以做基本的数学运算. [tough@localhost *|bc [tough@localhost expr ...