http://www.codeforces.com/problemset/problem/22/B

题意:求出n*m的方格图中全是0的矩阵的最大周长

思路:枚举

 #include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
int n,m,a[][],h[][];
char s[];
int read(){
int t=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
n=read();m=read();
for (int i=;i<=n;i++){
scanf("%s",s+);
for (int j=;j<=m;j++)
a[i][j]=s[j]-'';
}
for (int i=;i<=n;i++)
for (int j=;j<=m;j++){
if (a[i][j]) continue;
if (i!=&&a[i-][j]==) h[i][j]=h[i-][j]+;
else h[i][j]=;
}
int ans=;
for (int i=;i<=n;i++)
for (int j=;j<=m;j++)
if (a[i][j]==)
{
int ll=<<;
for (int k=j;k>=&&a[i][k]==;k--){
ll=std::min(ll,h[i][k]);
ans=std::max(ans,ll+j-k+);
}
}
printf("%d\n",ans*);
return ;
}

Codeforces 22B Bargaining Table的更多相关文章

  1. CodeForces 22B Bargaining Table 简单DP

    题目很好理解,问你的是在所给的图中周长最长的矩形是多长嗯用坐标(x1, y1, x2, y2)表示一个矩形,暴力图中所有矩形易得递推式:(x1, y1, x2, y2)为矩形的充要条件为: (x1, ...

  2. Code Forces 22B Bargaining Table

    B. Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. CF 22B. Bargaining Table

    水题.好久没有写过优化搜索题了. #include <cstdio> #include <cstring> #include <iostream> #include ...

  4. 暴力/DP Codeforces Beta Round #22 (Div. 2 Only) B. Bargaining Table

    题目传送门 /* 题意:求最大矩形(全0)的面积 暴力/dp:每对一个0查看它左下的最大矩形面积,更新ans 注意:是字符串,没用空格,好事多磨,WA了多少次才发现:( 详细解释:http://www ...

  5. Codeforces 417E Square Table(随机算法)

    题目链接:Codeforces 417E Square Table 题目大意:给出n和m.要求给出一个矩阵,要求每一列每一行的元素的平方总和是一个平方数. 解题思路:构造.依照 a a a b a a ...

  6. Bargaining Table

    Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  7. CodeForces 1099E - Nice table - [好题]

    题目链接:https://codeforces.com/problemset/problem/1099/E You are given an $n×m$ table, consisting of ch ...

  8. codeforces 582A. GCD Table 解题报告

    题目链接:http://codeforces.com/problemset/problem/582/A 网上很多题解,就不说了,直接贴代码= = 官方题解: http://codeforces.com ...

  9. codeforces D. Multiplication Table

    http://codeforces.com/contest/448/problem/D 题意:一个n×m的矩阵,a[i][j]=i*j; 然后把a数组排序,找出第k个数. 思路:1-n×m二分枚举,然 ...

随机推荐

  1. Shell循环处理

    date=`echo $1 | tr -d '-'` date1=`echo $1` date_end=`get_date $2 +1 | sed 's/-//g'` while [ 1 ] do d ...

  2. crossdomain.xml跨越

    crossdomain.xml是adobe搞的,为了让flash跨域访问文件. 该配置文件放于服务器端的根目录下面.来设置让哪些域名下面的swf文件能够访问我服务器上的内容. 比如:我的服务器上有个图 ...

  3. java中实现查看今天是星期几的代码实现

    public void getDate() { String[] weekDays = {"星期日", "星期一", "星期二", &quo ...

  4. HDU_2023——求平均成绩

    Problem Description 假设一个班有n(n<=50)个学生,每人考m(m<=5)门课,求每个学生的平均成绩和每门课的平均成绩,并输出各科成绩均大于等于平均成绩的学生数量. ...

  5. hdu-1598

    思路: 首先如果想到了Kruskal算法,那么下一步我们可能马上会想:那我们就从头开始写这个算法吧.然后一写就很容易发现一个问题——如果按照正常的Kruskal算法来做,那么start到end的舒适度 ...

  6. hadoop2.2.0 MapReduce的序列化

    package com.my.hadoop.mapreduce.dataformat; import java.io.DataInput;import java.io.DataOutput;impor ...

  7. [Git] Automatically running tests before commits with ghooks

    Wouldn't it be nice if everyone ran the tests before committing code? With ghooks, you can automatic ...

  8. USB HID Report Descriptor 报告描述符详解

    Report descriptors are composed of pieces of information. Each piece of information is called an Ite ...

  9. 编译lua5.3.2报错提示libreadline.so存在未定义的引用解决方法

    从官网上下载5.3.2的源码后,make linux进行编译,提示报错: gcc -std=gnu99 -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline ...

  10. Kinect研究

    1. 深度照相机 红外 + 2个摄像头. (1彩色摄像头,1红外发射,1接收) 红外捕捉深度. 2. OpenNI 某编程社区创建. 提供基本深度数据的访问.LGPL协议. 用户跟踪付费. 3. 问题 ...