Code Forces 22B Bargaining Table
来源:互联网 发布:新的网络安全法 编辑:程序博客网 时间:2024/06/05 22:36
Bob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room n × m meters. Each square meter of the room is either occupied by some furniture, or free. A bargaining table is rectangular, and should be placed so, that its sides are parallel to the office walls. Bob doesn't want to change or rearrange anything, that's why all the squares that will be occupied by the table should be initially free. Bob wants the new table to sit as many people as possible, thus its perimeter should be maximal. Help Bob find out the maximum possible perimeter of a bargaining table for his office.
The first line contains 2 space-separated numbers n and m (1 ≤ n, m ≤ 25) — the office room dimensions. Then there follow n lines withm characters 0 or 1 each. 0 stands for a free square meter of the office room. 1 stands for an occupied square meter. It's guaranteed that at least one square meter in the room is free.
Output one number — the maximum possible perimeter of a bargaining table for Bob's office room.
3 3000010000
8
5 411000000000000000000
16
暴力
#include <iostream>#include <string.h>#include <stdlib.h>#include <algorithm>#include <math.h>#include <stdio.h>using namespace std;int n,m;char a[30][30];int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%s",a[i]+1); bool tag=true; int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(a[i][j]=='1') continue; //cout<<a[i][j]<<endl; for(int l=1;l+i-1<=n;l++) { for(int r=1;r+j-1<=m;r++) { tag=true; for(int k=i;k<=i+l-1;k++) { for(int p=j;p<=r+j-1;p++) { if(a[k][p]=='1') { tag=false;break; } } if(!tag) break; } if(tag) ans=max(ans,(l+r)*2); } } } } printf("%d\n",ans); return 0;}
- Code Forces 22B Bargaining Table
- Codeforce 22B Bargaining Table
- Codeforce 22B Bargaining Table
- Codeforces 22B Bargaining Table
- codeforces 22B B. Bargaining Table(dp)
- codeforces 22B Bargaining Table dp
- CodeForces 22B Bargaining Table (简单题)
- Codeforces 22B Bargaining Table【暴力+思维】
- Codeforces Beta Round #22 (Div. 2 Only)-B. Bargaining Table
- Code forces 699B
- Bargaining Table
- CodeForces 22B Bargaining Table 01矩阵求最大矩形面积
- cf#22-B-Bargaining Table-枚举+贪心+dp(最大连续区间和)
- 【打CF,学算法——二星级】Codeforces 22B Bargaining Table(区域和)
- code forces 404B Marathon
- code forces 408B Garland
- Code Forces 242 B. Big Segment 贪心
- Code Forces 271B 预处理+预处理
- OpenGL ES像素着色器教程
- Soket服务端多任务与阻塞超时
- ssl2206 最小花费
- hiho练习“Drinking Game"二分搜索
- mysql二进制日志文件中的事件
- Code Forces 22B Bargaining Table
- PHP使用pear实现mail发送功能 windows环境下配置pear
- 第6周项目4-静态成员应用
- iOS CocoaPods安装和使用
- java.net.UnknownHostException
- 比较好的按键处理方法以及实例
- 数据库理论之ACID和BASE的比较
- 演示request的常用方法
- Java线程创建和启动