CF 22B. Bargaining Table
水题。好久没有写过优化搜索题了。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
char str[][];
int r[][];
int c[][];
int judge(int rx,int ry,int lx,int ly)
{
int i,j;
for(i = lx;i <= rx;i ++)
{
for(j = ly;j <= ry;j ++)
{
if(str[i-][j-] == '')
return ;
}
}
return ;
}
int main()
{
int n,m,i,j,k,u,ans;
scanf("%d%d",&n,&m);
for(i = ;i < n;i ++)
scanf("%s",str[i]);
ans = ;
for(i = ;i <= n;i ++)
{
for(j = ;j <= m;j ++)
{
if(str[i-][j-] == '')
{
r[i][j] = r[i-][j] + ;
c[i][j] = c[i][j-] + ;
}
else
{
r[i][j] = ;
c[i][j] = ;
}
}
}
for(i = n;i >= ;i --)
{
for(j = m;j >= ;j --)
{
for(k = ;k <= r[i][j];k ++)
{
for(u = ;u <= c[i][j];u ++)
{
if(ans >= (k+u)*) continue;
if(judge(i,j,i-k+,j-u+))
{
ans = max(ans,(k+u)*);
}
}
}
}
}
printf("%d\n",ans);
return ;
}
CF 22B. Bargaining Table的更多相关文章
- Code Forces 22B Bargaining Table
B. Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces 22B Bargaining Table
http://www.codeforces.com/problemset/problem/22/B 题意:求出n*m的方格图中全是0的矩阵的最大周长 思路:枚举 #include<cstdio& ...
- CodeForces 22B Bargaining Table 简单DP
题目很好理解,问你的是在所给的图中周长最长的矩形是多长嗯用坐标(x1, y1, x2, y2)表示一个矩形,暴力图中所有矩形易得递推式:(x1, y1, x2, y2)为矩形的充要条件为: (x1, ...
- Bargaining Table
Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- 暴力/DP Codeforces Beta Round #22 (Div. 2 Only) B. Bargaining Table
题目传送门 /* 题意:求最大矩形(全0)的面积 暴力/dp:每对一个0查看它左下的最大矩形面积,更新ans 注意:是字符串,没用空格,好事多磨,WA了多少次才发现:( 详细解释:http://www ...
- CF 71C. Round Table Knights
题目链接 很多小的细节都没想到... #include <cstdio> #include <cstring> #include <iostream> #inclu ...
- CF#338D. GCD Table
传送门 简单的中国剩余定理练习. 首先行数一定是$lcm$,然后只要确定最小的列数就能判定解合不合法了. 我们可以得到线性模方程组: $y \equiv 0 \pmod{a_1}$ $y+1 \equ ...
- CF 662C Binary Table
用FWT优化计算. 首先发现行数很小,想到一个暴力的方法,就是以一个二进制位$0$表示这一行不翻转而二进制位$1$表示这一行翻转,然后$2^n$枚举出所有行的翻转情况,再$O(m)$计算所有的结果. ...
- CF dp 题(1500-2000难度)
前言 从后往前刷 update 新增 \(\text{\color{red}{Mark}}\) 标记功能,有一定难度的题标记为 \(\text{\color{red}{红}}\) 色. 题单 (刷过的 ...
随机推荐
- Delphi函数的返回值(注意这里与C/C++等语言有差异)
在C/C++等语言中,函数执行到 return 部分之后,将立即停止函数的执行,并返回值 但是在Delphi中不同 函数中,执行到result时,并不同于比如 C/C++ 中的 return,跳出函数 ...
- 编程风格规范google版
python's coding style,google 命名
- C# SMTP邮件发送 分类: C# 2014-07-13 19:10 334人阅读 评论(1) 收藏
邮件发送在网站应用程序中经常会用到,包括您现在看到的博客,在添加评论后,系统会自动发送邮件通知到我邮箱的,把系统发送邮件的功能整理了下,做了一个客户端Demo,希望对有需要的童鞋有所帮助: 核心代码: ...
- Win10 UAP 绑定
Compiled DataBinding in Windows Universal Applications (UAP) http://nicksnettravels.builttoroam.com/ ...
- WPF ListView展示层叠信息
通常我们在ListView中展示一列同类数据,例如城市名称.不过可以对ListView的DataTemplate稍作修改,让其显示层叠信息.例如:需要在ListView中显示省份和省份对应的城市名称. ...
- hdu 4389 数位dp
求区间内满足x%fx==0的数的个数,fx为该数各个位数上的数字之和Sample Input21 1011 20 Sample OutputCase 1: 10Case 2: 3 大小不是你想开,想开 ...
- C# 使用 NPOI 库读写 Excel 文件
NPOI 是开源的 POI 项目的.NET版,可以用来读写Excel,Word,PPT文件.在处理Excel文件上,NPOI 可以同时兼容 xls 和 xlsx.官网提供了一份 Examples,给出 ...
- OpenCv for Android
Android开发:安装NDK,移植OpenCV2.3.1,JNI调用OpenCV全过程http://blog.csdn.net/yanzi1225627/article/details/852572 ...
- How to AC it
旋转卡壳 DP,网络流
- 使用nginx做负载均衡的session共享问题
查了一些资料,看了一些别人写的文档,总结如下,实现nginx session的共享PHP服务器有多台,用nginx做负载均衡,这样同一个IP访问同一个页面会被分配到不同的服务器上,如果session不 ...