Codeforces 22B Bargaining Table
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的更多相关文章
- CodeForces 22B Bargaining Table 简单DP
题目很好理解,问你的是在所给的图中周长最长的矩形是多长嗯用坐标(x1, y1, x2, y2)表示一个矩形,暴力图中所有矩形易得递推式:(x1, y1, x2, y2)为矩形的充要条件为: (x1, ...
- Code Forces 22B Bargaining Table
B. Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- CF 22B. Bargaining Table
水题.好久没有写过优化搜索题了. #include <cstdio> #include <cstring> #include <iostream> #include ...
- 暴力/DP Codeforces Beta Round #22 (Div. 2 Only) B. Bargaining Table
题目传送门 /* 题意:求最大矩形(全0)的面积 暴力/dp:每对一个0查看它左下的最大矩形面积,更新ans 注意:是字符串,没用空格,好事多磨,WA了多少次才发现:( 详细解释:http://www ...
- Codeforces 417E Square Table(随机算法)
题目链接:Codeforces 417E Square Table 题目大意:给出n和m.要求给出一个矩阵,要求每一列每一行的元素的平方总和是一个平方数. 解题思路:构造.依照 a a a b a a ...
- Bargaining Table
Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- CodeForces 1099E - Nice table - [好题]
题目链接:https://codeforces.com/problemset/problem/1099/E You are given an $n×m$ table, consisting of ch ...
- codeforces 582A. GCD Table 解题报告
题目链接:http://codeforces.com/problemset/problem/582/A 网上很多题解,就不说了,直接贴代码= = 官方题解: http://codeforces.com ...
- codeforces D. Multiplication Table
http://codeforces.com/contest/448/problem/D 题意:一个n×m的矩阵,a[i][j]=i*j; 然后把a数组排序,找出第k个数. 思路:1-n×m二分枚举,然 ...
随机推荐
- poj3237 Tree
Description You are given a tree with N nodes. The tree’s nodes are numbered 1 through N and its edg ...
- CSS 代码是什么?(转)
转自:http://www.divcss5.com/rumen/r95.shtml CSS 代码是什么,什么是CSS代码? 目录 什么是CSS css代码样子(图) 作用 相关扩展阅读 一.了解什么是 ...
- Jquery css函数用法(判断标签是否拥有某属性)
判断一个层是否隐藏:$("#id").css("display")=="none" ;在所有匹配的元素中,设置一个样式属性的值:$(&qu ...
- final(最终、修饰符)
/* final(最终.修饰符) final关键字的用法: 1. final关键字修饰一个基本类型的变量时,该变量不能重新赋值,第一次的值为最终的. 2. fianl关键字修饰一个引用类型变量时,该变 ...
- BeanFactory调用getbean()对象
Spring通过资源加载器加载相应的XML文件,使用读取器读取资源加载器中的文件到读取器中,在读取过程中,解析相应的xml文件元素,转化为spring定义的数据结BeanDefinition,把相应的 ...
- DataGrid横向滚动条无法拖动的问题
项目中经常遇到一些问题,这些问题可能很简单,但是之前从未遇到,可能经过了一番谷歌,也可能是查阅了MSDN,或是借鉴了大牛博客,逐渐有了些眉目,为了将这些东西落地,也为了将来之不易的东西记录下来,以备今 ...
- Hibernate介绍
1.什么是Hibernate? 首先,Hibernate是数据持久层的一个轻量级框架.数据持久层的框架有很多比如:iBATIS,myBatis,Nhibernate,Siena等等. 并且Hibern ...
- Redis环境搭建(Linux)
1.简介 redis是一个开源的key-value数据库.它又经常被认为是一个数据结构服务器.因为它的value不仅包括基本的string类型还有 list,set ,sorted set ...
- sql列转行
1.需要实现一个单行的统计报表 思路先用一个union查出单列,然后再把单列转成单行 2.实现 SELECT MAX(CASE WHEN type = 1 THEN num ELSE 0 END) A ...
- include子页面传递过来的参数传递到后台
在页面上可以使用 ${param.moduleId}来获取 在判断中也可以使用${param.moduleId == "test" ? "1":"2& ...