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二分枚举,然 ...
随机推荐
- win7 共享
1.取得IP 3. 输入 用户名 和密码就可以了
- HDOJ 1323 Perfection(简单题)
Problem Description From the article Number Theory in the 1994 Microsoft Encarta: "If a, b, c a ...
- 组播报文转发过程RPF
单播报文的转发过程中,路由器并不关心组播源地址,只关心报文中的目的地址,通过目的地址决定向哪个接口转发.在组播中,报文是发送给一组接收者的,这些接收者用一个逻辑地址标识.路由器在接收到报文后,必须根据 ...
- CentOS 设置mysql的远程访问
好记性不如烂笔头,记录一下. 安装了MySQL默认是拒绝远程连接的. 首先进入数据库,使用系统数据库mysql. mysql -u root -p mysql #回车,然后输入则使用了系统数据库 接着 ...
- OSI七层以及各层上的协议
各层简介: [1]物理层:主要定义物理设备标准,如网线的接口类型.光纤的接口类型.各种传输介质的传输速率等.它的主要作用是传输比特流(就是由1.0转化为电流强弱来进行传输,到达目的地后在转化为1.0, ...
- C语言自动类型转换
自动转换遵循以下规则: 1) 若参与运算量的类型不同,则先转换成同一类型,然后进行运算. 2) 转换按数据长度增加的方向进行,以保证精度不降低.(eg:int型和long型运算时,先把int量转成lo ...
- lesson1:threadlocal的使用demo及源码分析
本文中所使用的demo源码地址:https://github.com/mantuliu/javaAdvance 其中的类Lesson1ThreadLocal 本文为java晋级系列的第一讲,后续会陆续 ...
- SOA——面向服务的体系架构
上一篇博文中提到了"紧耦合"的现象.怎样解决?SOA.採用面向服务的体系架构. 一.What? SOA=Service-oriented Architecture面向服务的体系结构 ...
- [Angular 2] Filter items with a custom search Pipe in Angular 2
This lessons implements the Search Pipe with a new SearchBox component so you can search through eac ...
- MVC三和,你能辨别它?
上次我们聊的时间MVC,而之前我们学习过三层.那么我们不禁就要问,他们说的是一回事吗.他们有什么联系吗? 三层架构(3-tier application)通常意义上的三层架构就是将整个业务应用划分为: ...