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

  1. (x1, y1, x2, y2) 和 (x1, y1, x2, y2)为合法矩形,即全部为0
  2. Point(x2, y2) 为 0

当然对X1 == X2这种特殊情况需要特殊判断一下。

Source Code:

//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max (a,b) (((a) > (b)) ? (a) : (b))
#define Min (a,b) (((a) < (b)) ? (a) : (b))
#define Abs (x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template <class T> inline void checkmin (T &a,T b) { if (a > b) a = b; }
template <class T> inline void checkmax (T &a,T b) { if (a < b) a = b; } const double eps = 1e- ;
const int N = ;
const int M = ;
const ll P = 10000000097ll ;
const int INF = 0x3f3f3f3f ; char a[][];
bool cc[][][][];
int n, m; bool check(int x1, int y1, int x2, int y2){
if(x1 >= && x1 <= n){
if(x2 >= x1 && x2 <= n){
if(y1 >= && y1 <= m){
if(y2 >= y1 && y2 <= m){
return true;
}
}
}
}
return false;
} int main(){
int i, j, k, t, numCase = ;
while(cin >> n >> m){
memset(cc, , sizeof(cc));
for(i = ; i <= n; ++i){
for(j = ; j <= m; ++j){
cin >> a[i][j];
}
}
int ans = ;
for(int x1 = ; x1 <= n; ++x1){
for(int x2 = x1; x2 <= n; ++x2){
for(int y1 = ; y1 <= m; ++y1){
for(int y2 = y1; y2 <= m; ++y2){
if((x2 == x1 || check(x1, y1, x2 - , y2)) && (y2 == y1 || check(x1, y1, x2, y2 - )) && a[x2][y2] == ''){
if((x2 == x1 || cc[x1][y1][x2 - ][y2]) && (y1 == y2 || cc[x1][y1][x2][y2 - ])){
cc[x1][y1][x2][y2] = true;
checkmax(ans, * (x2 - x1 + + y2 - y1 + ));
}
} }
}
}
}
cout << ans << endl;
} return ;
}

CodeForces 22B Bargaining Table 简单DP的更多相关文章

  1. Codeforces 22B Bargaining Table

    http://www.codeforces.com/problemset/problem/22/B 题意:求出n*m的方格图中全是0的矩阵的最大周长 思路:枚举 #include<cstdio& ...

  2. Code Forces 22B Bargaining Table

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

  3. Codeforces 1108D - Diverse Garland - [简单DP]

    题目链接:http://codeforces.com/problemset/problem/1108/D time limit per test 1 secondmemory limit per te ...

  4. Codeforces - 702A - Maximum Increase - 简单dp

    DP的学习计划,刷 https://codeforces.com/problemset?order=BY_RATING_ASC&tags=dp 遇到了这道题 https://codeforce ...

  5. Codeforces - 1081C - Colorful Bricks - 简单dp - 组合数学

    https://codeforces.com/problemset/problem/1081/C 这道题是不会的,我只会考虑 $k=0$ 和 $k=1$ 的情况. $k=0$ 就是全部同色, $k=1 ...

  6. Codeforces - 474D - Flowers - 构造 - 简单dp

    https://codeforces.com/problemset/problem/474/D 这道题挺好的,思路是这样. 我们要找一个01串,其中0的段要被划分为若干个连续k的0. 我们设想一个长度 ...

  7. Codeforces - 909C - Python Indentation - 简单dp

    http://codeforces.com/problemset/problem/909/C 好像以前做过,但是当时没做出来,看了题解也不太懂. 一开始以为只有上面的for有了循环体,这里的state ...

  8. CodeForces 30C Shooting Gallery 简单dp

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qq574857122/article/details/36944227 题目链接:点击打开链接 给定 ...

  9. Codeforces - 1033C - Permutation Game - 简单dp - 简单数论

    https://codeforces.com/problemset/problem/1033/C 一开始觉得自己的答案会TLE,但是吸取徐州赛区的经验去莽了一发. 其实因为下面这个公式是 $O(nlo ...

随机推荐

  1. selenium + python自动化测试环境搭建--亲测

    环境准备: 1.下载所学安装包: setuptools https://pypi.python.org/packages/2.7/s/setuptools/ selenium https://pypi ...

  2. Java Socket 入门2 Java与C# Socket 通信

    参考http://www.cnblogs.com/cdtarena/p/3184313.html 这里以C#作为服务端  其实不论C#是服务端还是客户端都不是主要问题 毕竟不论客户端还是服务端 都包括 ...

  3. inlay检验标准

    Inlay 检验标准 检验条件及要求 正常的 40W 日光灯下距离被检物 50cm,眼睛距离被检物 30cm,与被检物呈 45 度角,目视检 使用强光灯箱透视其内部结构 适用范围 Inlay 中料 检 ...

  4. C++模板:读入优化

    int scan(int &x){ while(c=getchar(),c<'0'||c>'9');x=c-'0'; while(c=getchar(),c>='0'& ...

  5. poj 2001 Shortest Prefixes(字典树)

    题目链接:http://poj.org/problem?id=2001 思路分析: 在Trie结点中添加数据域childNum,表示以该字符串为前缀的字符数目: 在创建结点时,路径上的所有除叶子节点以 ...

  6. python下使用protobuf

    python解决ImportError: No module named google.protobuf 关于protocol buffer的优点,就过多涉及:如果涉及到数据传输和解析,使用pb会比自 ...

  7. JDBC初步(一)

    import java.sql.*; public class TestJDBC { // orcl为oracle数据库中的数据库名,localhost表示连接本机的oracle数据库 // 1521 ...

  8. Tableau Server 8.0 升级到 8.3 过程记录

    一.使用账号(管理员权限),安装文件复制到服务器 二.检查维护状态 如果维护状态过期,更新到新版本会变成未授权. 先进Manage Product Keys刷新一下维护日期(其实不刷新也无所谓.到时候 ...

  9. HTML5 总结-表单-输入类型

    HTML5 Input 类型 HTML5 新的 Input 类型 HTML5 拥有多个新的表单输入类型.这些新特性提供了更好的输入控制和验证. 本章全面介绍这些新的输入类型: email url nu ...

  10. 我用的比较少的CSS选择器

    选择器 描述 [attribute] 用于选取带有指定属性的元素. [attribute=value] 用于选取带有指定属性和值的元素. [attribute~=value] 用于选取属性值中包含指定 ...