题目很好理解,问你的是在所给的图中周长最长的矩形是多长
嗯用坐标(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. windows 7 里面的iis在哪里

    我的电脑------控制面板-----卸载程序------打开或关闭WINDOWS功能-----INTERNET信息服务------WEB管理工具下就能找到 给你找图你看看 向左转|向右转

  2. 帝国cms栏目死变量

    这里为帝国学习者们放出帝国学习者们会用到的栏目死变量,不需要灵动或者万能标签能调用,在任何位置都能使用 栏目路径:<?=$public_r[newsurl].$class_r[1]['class ...

  3. Qt的目录依赖问题----怎样生成一个绿色的Qt软件包

    Qt的目录依赖问题----怎样生成一个绿色的Qt软件包 一.核心问题: 如果将编译好的Qt文件拷贝到任何目录下,作为一个绿色软件库来使用? 二.原理讨论 由于Qt在编译的时候将安装路径硬编码到了库文件 ...

  4. cocos2d-x中的尺寸之三

    通过上面两个文章的分析,我们在这个博文里做个总结: CCEGLView::getFrameSize()返回的是窗口相对于屏幕像素的尺寸,这个尺寸,只要窗口没变化,值就不会变化 CCDirector:: ...

  5. HDU 4931 Happy Three Friends

    #include <cstdio> #include <algorithm> using namespace std; int p1,p2,a[6],T; int main() ...

  6. CERC 2013 Magical GCD

    题目大意如下:给定一个序列,每个序列有值xi,现给定t个数列,对于每个长n的数列,求一段[l,r]使 [r-l+1]*gcd(l,r)最大,gcd(l,r)指的是该连续区间的最大公约数. 不难想到n^ ...

  7. File类常用方法

    File类是IO中常用的类 先介绍几个常用的方法: public boolean canRead(),public boolean canWrite() 测试当前文件是否可读可写,若是则返回true ...

  8. 双网卡绑定(suse)

    网卡绑定技术有助于保证高可用性特性并提供其它优势以提高网络性能,Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,就是两块网卡具有相同的IP ...

  9. 1148 - Mad Counting(数学)

    1148 - Mad Counting   PDF (English) Statistics Forum Time Limit: 0.5 second(s) Memory Limit: 32 MB M ...

  10. CSS3学习笔记之linear-gradient

    我觉得CSS3很不错,自己也稍微看过,并且尝试过一些属性.对我自己而言,我没有勇气说我学过CSS3,我觉得任何自己看来很小的事情,也只是站在自己的角度来评判.就算的是"简单的"HT ...