City Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 4531    Accepted Submission(s): 1919

Problem Description
Bob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,factories and buildings. There is still some
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.
 
Input
The first line of the input contains an integer K – determining the number of datasets. Next lines contain the area descriptions. One description is defined in the following way: The first line contains two integers-area
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.
 
Output
For each data set in the input print on a separate line, on the standard output, the integer that represents the profit obtained by erecting the largest building in the area encoded by the data set.
 
Sample Input
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
 
Sample Output
45
0
 
Source

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)的更多相关文章

  1. HDU 1505 City Game (hdu1506 dp二维加强版)

    F - City Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submi ...

  2. HDU 1505 Largest Rectangle in a Histogram &amp;&amp; HDU 1506 City Game(动态规划)

    1506意甲冠军:给你一个连续的直方图(拼贴底部长度1).求连续基质区. 对每一个直方图,分别向左向右进行扩展. #include<cstdio> #include<stdlib.h ...

  3. HDU 5791:Two(DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=5791 Two Problem Description   Alice gets two sequences A ...

  4. HDU 4833 Best Financing(DP)(2014年百度之星程序设计大赛 - 初赛(第二轮))

    Problem Description 小A想通过合理投资银行理财产品达到收益最大化.已知小A在未来一段时间中的收入情况,描述为两个长度为n的整数数组dates和earnings,表示在第dates[ ...

  5. HDU 1505 City Game(01矩阵 dp)

    Problem Description Bob is a strategy game programming specialist. In his new city building game the ...

  6. HDU 4833 Best Financing (DP)

    Best Financing Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. HDU 1422 重温世界杯(DP)

    点我看题目 题意 : 中文题不详述. 思路 : 根据题目描述及样例可以看出来,如果你第一个城市选的是生活费减花费大于等于0的时候才可以,最好是多余的,这样接下来的就算是花超了(一定限度内的花超),也可 ...

  8. HDU 1176 免费馅饼(DP)

    点我看题目 题意 : 中文题.在直线上接馅饼,能接的最多是多少. 思路 :这个题其实以前做过.....你将这个接馅饼看成一个矩阵,也不能说是一个矩阵,反正就是一个行列俱全的形状,然后秒当行,坐标当列, ...

  9. hdu 4055 Number String(dp)

    Problem Description The signature of a permutation is a string that is computed as follows: for each ...

随机推荐

  1. python note of class

    reference: https://www.zhihu.com/question/27699413/answer/267906889 摘要: 我们在描述一个真实对象(物体)时包括两个方面:它可以做什 ...

  2. jquery.form.min.js

    /*! * jQuery Form Plugin * version: 3.51.0-2014.06.20 * Requires jQuery v1.5 or later * Copyright (c ...

  3. js获取当前位置

    <!DOCTYPE html><html><head><meta name="viewport" content="initia ...

  4. python书籍推荐:Python数据科学手册

    所属网站分类: 资源下载 > python电子书 作者:today 链接:http://www.pythonheidong.com/blog/article/448/ 来源:python黑洞网 ...

  5. python爬取百度文库所有内容

    转载自 GitHub 的 Jack-Cherish 大神 基本环境配置 版本:python3 系统:Windows 相关模块: import requests import re import jso ...

  6. Vue如何点亮多个tab选项简易方法

    我们平常遇到点击选择会遇到单选或多选,当你设计图是自定义的时候,第一反应就是引入UI插件吧.可是如果项目只用到插件的这一点点功能,我们引入了一个插件这就不太友好了.此时我们自己写这个小功能是很简单的, ...

  7. 解决Antimalware Service Executable CPU,内存占用高的问题

    1.win键+R键打开运行对话框框,输入gpedit.msc打开本地组策略编辑器(组策略):2.依次打开计算机配置-管理模板-Windows组件-Windows Defender:3.如果要关闭Win ...

  8. 在jupyter notebook 中编辑公式

    jupyter notebook是一个python的交互式开发环境,广泛应用于数据分析的场景下. 在jupyter notebook中,还可以很方便的编辑数学公式. 1.Markdown状态 编辑公式 ...

  9. 【02】AMD、CMD、UMD 模块的写法

    AMD.CMD.UMD 模块的写法 简介 最近几年,我们可以选择的Javascript组件的生态系统一直在稳步增长.虽然陡增的选择范围是极好的,但当组件混合匹配使用时就会出现很尴尬的局面.开发新手们会 ...

  10. xtu summer individual 5 F - Post Office

    Post Office Time Limit: 1000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID ...