HDU 1505 City Game(DP)
City Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4531 Accepted Submission(s): 1919
space in the area that is unoccupied. The strategic task of his game is to win as much rent money from these free spaces. To win rent money you must erect buildings, that can only be rectangular, as long and wide as you can. Bob is trying to find a way to
build the biggest possible building in each area. But he comes across some problems – he is not allowed to destroy already existing buildings, trees, factories and streets in the area he is building in.
Each area has its width and length. The area is divided into a grid of equal square units.The rent paid for each unit on which you're building stands is 3$.
Your task is to help Bob solve this problem. The whole city is divided into K areas. Each one of the areas is rectangular and has a different grid size with its own length M and width N.The existing occupied units are marked with the symbol R. The unoccupied
units are marked with the symbol F.
length M<=1000 and width N<=1000, separated by a blank space. The next M lines contain N symbols that mark the reserved or free grid units,separated by a blank space. The symbols used are:
R – reserved unit
F – free unit
In the end of each area description there is a separating line.
2
5 6
R F F F F F
F F F F F F
R R R F F F
F F F F F F
F F F F F F 5 5
R R R R R
R R R R R
R R R R R
R R R R R
R R R R R
45
0
1506的升级版 仅仅是多了一维 h要自己算 详情看上一篇
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1005;
int mat[N][N], le[N][N], ri[N][N], h[N][N], cas, n, m;
int main()
{
char s[5];
scanf ("%d", &cas);
while (cas--)
{
memset (mat, 0, sizeof (mat));
memset (h, 0, sizeof (h));
scanf ("%d%d", &n, &m); for (int i = 1; i <= n; ++i)
{
h[i][0] = h[i][m + 1] = -1;
for (int j = 1; j <= m; ++j)
{
scanf ("%s", s), mat[i][j] = s[0];
le[i][j] = ri[i][j] = j;
if (mat[i][j] == 'F') h[i][j] = h[i - 1][j] + 1;
}
} int ans = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = m; j >= 1; --j)
while (h[i][ri[i][j] + 1] >= h[i][j])
ri[i][j] = ri[i][ri[i][j] + 1]; for (int j = 1; j <= m; ++j)
{
while (h[i][le[i][j] - 1] >= h[i][j])
le[i][j] = le[i][le[i][j] - 1];
ans = max (ans, (ri[i][j] - le[i][j] + 1) * h[i][j]);
}
}
printf ("%d\n", ans * 3);
}
return 0;
}
HDU 1505 City Game(DP)的更多相关文章
- HDU 1505 City Game (hdu1506 dp二维加强版)
F - City Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submi ...
- HDU 1505 Largest Rectangle in a Histogram && HDU 1506 City Game(动态规划)
1506意甲冠军:给你一个连续的直方图(拼贴底部长度1).求连续基质区. 对每一个直方图,分别向左向右进行扩展. #include<cstdio> #include<stdlib.h ...
- HDU 5791:Two(DP)
http://acm.hdu.edu.cn/showproblem.php?pid=5791 Two Problem Description Alice gets two sequences A ...
- HDU 4833 Best Financing(DP)(2014年百度之星程序设计大赛 - 初赛(第二轮))
Problem Description 小A想通过合理投资银行理财产品达到收益最大化.已知小A在未来一段时间中的收入情况,描述为两个长度为n的整数数组dates和earnings,表示在第dates[ ...
- HDU 1505 City Game(01矩阵 dp)
Problem Description Bob is a strategy game programming specialist. In his new city building game the ...
- HDU 4833 Best Financing (DP)
Best Financing Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 1422 重温世界杯(DP)
点我看题目 题意 : 中文题不详述. 思路 : 根据题目描述及样例可以看出来,如果你第一个城市选的是生活费减花费大于等于0的时候才可以,最好是多余的,这样接下来的就算是花超了(一定限度内的花超),也可 ...
- HDU 1176 免费馅饼(DP)
点我看题目 题意 : 中文题.在直线上接馅饼,能接的最多是多少. 思路 :这个题其实以前做过.....你将这个接馅饼看成一个矩阵,也不能说是一个矩阵,反正就是一个行列俱全的形状,然后秒当行,坐标当列, ...
- hdu 4055 Number String(dp)
Problem Description The signature of a permutation is a string that is computed as follows: for each ...
随机推荐
- Oracle中如何插入特殊字符: &amp; 和 &#39; (多种解决方案)
Oracle中如何插入特殊字符:& 和 ' (多种解决方案)今天在导入一批数据到Oracle时,碰到了一个问题:Toad提示要给一个自定义变量AMP赋值,一开始我很纳闷,数据是一系列的Inse ...
- 【PS切图】前端工程师必备,但又无需精通的一项技能。
前端主要从事一些代码开发工作,PS使用是前端工程师必备,但又无需精通的一项技能. 前端切图四大面板:在“窗口”菜单下开启 1,信息(手动开启)2,字符(手动开启)3,历史记录(手动开启)4,图层(默认 ...
- 题解 洛谷P4550/BZOJ1426 【收集邮票】
这显然是一道概率的题目(废话) 设发\(f[i]\)表示买到第\(i\)张邮票还需要购买的期望次数,\(g[i]\)表示买到第\(i\)张邮票还需要期望花费的钱. 那么答案显然为\(g[0]\),我们 ...
- JavaScript之作用域和闭包
一.作用域 作用域共有两种主要的工作模型:第一种是最为普遍的,被大多数编程语言所采用的词法作用域,另外一种叫作动态作用域: JavaScript所采用的作用域模式是词法作用域. 1.词法作用域 词法作 ...
- pip各种
pip: 一个现代的,通用的 Python 包管理工具.提供了对Python 包的查找.下载.安装.卸载的功能. windows:自带pip,直接使用. Linux:执行下面命令即可完成安装. # w ...
- SpringMVC Controller的返回类型
Controller的三种返回类型中 ModelAndView类型 带数据带跳转页面 String 跳转页面不带数据 void 通常是ajax格式请求时使用 1返回ModelAndView contr ...
- List<> 集合 删除指定行
不多说,直接上代码 public class Name { public string NameInfo { get; set; } } 删除值为Name2的行 static void Main(st ...
- github some rank
github some rank http://githubrank.com/
- 前端开发:CSS3
CSS介绍: CSS能够使页面具有美观一致的效果,并且能够让内容与格式分离,利于扩展 所以,CSS解决了下面两个问题: 1. 将HTML页面的内容与格式分离: 2. 提高web开发的工作效率. CSS ...
- 【NOIP2015】运输计划(树上差分,二分答案)
题意:一棵有边权的树上有m条路径,要求选择一条边使其边权变为0,使得最大路径长度最小 n,m<=300000 思路:直接求最优方案不可做,但检验对于某一个ans是否能有方案是可行的 取出所有总长 ...