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 ...
随机推荐
- pytorch之Tensor与Variable的区别
首先在变量的操作上:Tensor对象支持在原对象内存区域上修改数据,通过“+=”或者torch.add()方法而Variable不支持在原对象内存区域上修改数据Variable对象可求梯度,并且对Va ...
- wampsever修改数据库密码
①进入localhost中的mysql数据库 ②再进入mysql数据库中的user表 ③将user表中的三个root账号的密码全部改为你想要的密码(不需要经过MD5加密) ④保存后重新启动服务 如果在 ...
- 第二次 Ubuntu16.04 vi编辑器的方向键和退格问题
新安装ubuntu后,好多人可能都碰到过这样的问题,vi对文件进行编辑时,上下左右键变成了ABDC,退格键也不管用. 解决办法其实也很简单,首先卸载掉旧的vim-common. apt-get rem ...
- assert.fail()详解
assert.fail(actual, expected, message, operator) 抛出一个 AssertionError.如果 message 是假值,错误信息会被设置为被 opera ...
- PDO、PDOStatement、PDOException
最近在学PDO 比较详细的资料 出处:http://blog.csdn.net/hsst027/article/details/23682003 PDO中包含三个预定义的类,它们分别是PDO.PDO ...
- Linux最常用的基础命令 上篇
Linux最常用的基础命令个人总结 计算机基础知识 32bit和64bit系统的区别.系统运行机制 1989年python 诞生 C语言是编译型的语言,不太支持跨平台 Django 江购 32bit= ...
- HttpURLConnection绕过HTTPS的SSL验证
(这个jdk环境需要是1.8,以上). 直接在类里面加一个static代码块 static { try { trustAllHttpsCertificates(); HttpsURLConnectio ...
- postman工具的应用实战(二)
在接口测试工具中,最好的应该是soapui,jmeter,postman,但是soapui需要安装和破解,当然也是有破解版的,但是不够灵活,jmeter工具 做接口测试还是性能测试,功能测试,都是一个 ...
- spark streaming基于Kafka的开发
spark streaming使用Kafka数据源进行数据处理,本文侧重讲述实践使用. 一.基于receiver的方式 在使用receiver的时候,如果receiver和partition分配不当, ...
- [luoguP1013] 进制位(搜索)
传送门 纯搜索,无优化! #include <cstdio> #include <cstring> #include <iostream> #include < ...