HDU 1505 City Game (DP)

『杭电1505』City Game 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 th 阅读详情

http://acm.hdu.edu.cn/showproblem.php?pid=1505


City Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3929    Accepted Submission(s): 1637


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
 



(这游戏是大富翁?)圈一个最大的矩形,F可圈,R不可,HDU1506的高级版(1506链接:http://acm.hdu.edu.cn/showproblem.php?pid=1506,解题报告:http://blog.csdn.net/u012965890/article/details/19646851)每一行都当做1506中的X轴更新直方图高度,R就是0


#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<cctype>
#include<cmath>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#define sqr(x) (x)*(x)
#define INF 0x1f1f1f1f
#define PI 3.1415926535
#define LL long long
#define mm 1001

using namespace std;

int l[mm],r[mm],up[mm],map[mm][mm];
int n,m;
int area,maxarea;
char s[10];

void solve(int x)
{
	int i,j;
	
	for (i=1;i<m;i++)
	{
		while(l[i]-1>=0 && map[x][l[i]-1]>=map[x][i])
		{
			l[i]=l[l[i]-1];
		}
	}
	for (i=m-2;i>=0;i--)
	{
		while (r[i]+1<m && map[x][r[i]+1]>=map[x][i])
		{
			r[i]=r[r[i]+1];
		}
	}
	for (i=0;i<m;i++)
	{
		maxarea=max(maxarea,map[x][i]*(r[i]-l[i]+1));
	}
}

int main()
{
	int tt;
	scanf("%d",&tt);
	while(tt--)
	{
		scanf("%d%d",&n,&m);getchar();
		maxarea=0;
		memset(map,0,sizeof(map));
		for (int i=1;i<=n;i++)
		{
			
			for (int j=0;j<m;j++)
			{
				scanf("%s",s);
				if (s[0]=='F')
					map[i][j]=map[i-1][j]+1;
				
				
				l[j]=r[j]=j;
				
			}
			solve(i);
		}
		printf("%d\n",maxarea*3);
		
	}
	
	
	return 0;
}


城市群快速生成插件GSG_CityKit_1.2 城市群快速生成插件GSG_CityKit_1.2 内附安装教程 立即下载

相关推荐

【经验分享】使用Keil5烧录代码遇到的问题及解决方法

本文介绍了在使用Keil5烧录代码过程中可能遇到的常见问题,主要为编译错误和下载失败,并提供了解决方案和注意事项。通过本文中提供的具体解决方案和注意事项,希望能够帮助读者更加顺利地进行Keil5烧录代码操作,提高开发效率和成果实现。

qq_63195670的博客 1万+

【UVA1330】City game

题面   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 b

清疚的博客 591

LaTeX参考文献格式apsrev4-1,增加文献标题

APS的LaTeX参考文献格式apsrev4-1是隐藏标题的,如果想要出现标题,需要更改apsrev4-1.bst文件内容 在apsrev4-1.bst文件靠后部分,定义不同类型文献格式的地方,将article类型的内容替换为, FUNCTION {article} { output.bibitem format.authors booktitle empty$ { "author" output.check }{ output } if$ author format.

loading1234567的博客 5034

【DP】 hdu1505 City Game

City Game http://acm.hdu.edu.cn/showproblem.php?pid=1505 Problem Description Bob is a strategy game programming specialist. In his new city building game the gaming environment is as foll

Ted's 游乐园 2680

实战指南:基于ELK与Grafana构建天融信防火墙日志可视化看板

本文详细介绍了如何基于ELK与Grafana构建天融信防火墙日志可视化看板,包括环境准备、日志收集与解析配置、Elasticsearch存储优化、Grafana看板设计等关键步骤。通过实战案例和优化技巧,帮助用户高效处理天融信防火墙日志,实现安全态势的可视化监控与分析。

weixin_34246529的博客 229

浮点数精度陷阱全解析:从IEEE 754到深度学习部署选型

在计算机数值计算中,浮点数是表示带小数数字的标准方式,但它的存储规则决定了精度和边界天生存在限制。许多开发者都曾遭遇过0.1+0.2不等于0.3的尴尬,或是模型训练中loss变成NaN的困扰,这些问题的根源往往指向IEEE 754标准中的规格化、非规格化表示及舍入规则。理解浮点数的底层原理,不仅能避开直接的比较判断陷阱,还能指导我们在不同场景下做出合理的技术选型。从C语言的printf到Python的repr,从嵌入式串口打印到深度学习中的FP32、FP16、BF16、TF32格式,浮点数知识贯穿底层开发和

weixin_34314962的博客 466

杭电 1505 动态规划

这道题基本上和杭电2870是一样的,代码绝大部分都一样。题目: City Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2011 Accepted Submission(s): 809 Problem Descr

938

实现高精度卷积混响--MATLAB仿真篇

一、前言 之前在STM32F407上现实了直播声卡,实现的经典Schroeder混响模型和Moorer混响模型,得到不错效果。后来得知卷积混响最为真实地表现空间的特性,所以也就尝试在MCU上实现一个高精度的卷积混响(卷积点数为32768),目前MCU出来的混响效果算得上一流水准,本人也在计划在ADI的21489或者SC584上更高精度的卷积混响。 二、卷积方式 1、conv1是使用MATLAB自带卷积函数conv 2、conv2和conv3是改进后卷积过程,具有减少运算量特点,方便嵌入式移植 clear;

Six44的博客 5086

HDU 1505 City Game(DP求二维最大子矩阵)

City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5913    Accepted Submission(s): 2533 Problem Description Bob is a strategy ga

HHH的专栏 446

手把手教你解决Realsense D455在ROS下IMU数据不输出的问题(附固件降级指南)

本文详细解析了Realsense D455在ROS环境下IMU数据不输出的问题,提供了固件降级和ROS配置的完整解决方案。通过版本兼容性分析和实战操作指南,帮助开发者快速恢复IMU数据流,优化机器人开发体验。

weixin_42531494的博客 379

系统建模语言 (SysML)

系统建模语言

追赶时代的博客 756

HDU-1505-City Game【dp】【思维】

HDU-1505-City Game

Linoy 1190

【ESP 保姆级教程】玩转emqx数据集成篇④ ——数据桥接之HTTP服务

主要是学习数据桥接功能以及构建自己的http服务器,这是一个非常有用的功能。包括各种传感器上报基本上都需要数据桥接功能支持,所以还是希望认真学习这一块开发,然后结合数据库存储等等知识点进行进一步学习。

单片机菜鸟哥的博客 1309

HDU 1505 City Game(DP)

1506的升级版 只是多了一维 h要自己算 详情看上一篇

Good morning,good afternoon and good night 1063

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

hdu1505 City Game(DP)

思路:HDU1506的加强版,只要把算出以i 行为底能达到的最到的最大高度,再扫描每一行,就转化为 HDU1506 的问题了 #include using namespace std; const int maxn = 1005; int a[maxn][maxn]; int l[maxn],r[maxn]; int main() { int T; scanf("%d",&T);

围巾的ACM博客 284

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

HDU1505 City Game (DP,HDU1506加强版)

链接: http://acm.hdu.edu.cn/showproblem.php?pid=1505 没做过1506的建议先去做1506,我有详细解释 1506链接:http://blog.csdn.net/xtttgo/article/details/48085707 因为我是用1506的方法做的这题 题意:R是障碍物,求最大的F形成的矩形 实际上,我们把R的情况去掉,就是跟150

xtttgo的博客 387

贝叶斯统计 [韦来生编]

贝叶斯(Bayes)统计是近几十年来迅速发展起来的数理统计的一个重要分支。贝叶斯方法与经典统计方法的主要不同之处是进行统计推断时除了利用样本信息外,还要利用参数的先验信息,因此可以提高统计推断或统计决策的效果。它在经济、金融、生物、医学、自然科学和社会科学等许多领域具有广泛的应用。贝叶斯方法的研究已渗透到了统计学的几乎所有领域。作者在给中国科学技术大学概率论与数理统计专业本科生开设的“数理统计”课程中有一章专门讲授“贝叶斯方法和统计决策理论”,近十年来也给中国科学技术大学概率统计专业研究生开设过几次“贝叶斯分析”课。本书是在对过去讲稿的内容作了适当的增减和调整的基础上完成的。  本书共分六章。第1章是绪论,介绍了贝叶斯统计的若干基本概念,同时对必要的数理统计的基础知识有重点地作了回顾。第二章介绍了确定先验分布的若干可供选择的方法。第三章介绍了几类常见统计模型参数的后验分布的主要结果和计算方法。第四章和第五章分别介绍了“贝叶斯统计推断”和“贝叶斯统计决策”的内容。第六章介绍了贝叶斯统计计算的若干方法,包括蒙特卡洛方法和马尔可夫链蒙特卡洛(MCMC)方法以及相关统计软件的简介。本书的每一章附右大量的例题和习题,书末附有常用的几个表格和部分习题解答供读者查用。  大约可在54学时内讲授本书的第1章至第六章的主要内容,教师可根据学时需要选讲本书第1章至第六章的部分内容。书中标“*”号的章节可略去不讲,留给读者作为阅读材料。第六章例题中的R代码和部分例题的数据文件等可从作者个人主页下载。  作者在编写本书的过程中参考了J.O.Berger教授的《统计决策论及贝叶斯分析》和茆诗松教授编写的《贝叶斯统计》等书中的一些内容,以及《贝叶斯分析》一书中由张伟平博士编写的有关贝叶斯统计计算的一些内容。在此表示衷心感谢。  本书编写准备过程中,中国科学技术大学统计与金融系的几个研究生帮助完成了本书部分中文的录入和排版,作者对他们的辛勤工作表示真诚的感谢。高等教育出版社为本书的出版给予了大力支持。在此一并致谢。

hdu 1505 City Game dp

题意:最大F子矩阵 * 3 每行处理出里(i,j)最左最有的不小于mat【i】【j】的数组,然后更新答案 #include #include #include #include #include #include #include #include #include #include #include ///cout << fixed << setprecision(

uuuuuu 345

hdu1505city game dp

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

MissZhou要努力 702

hdu 1505 City Game dp

给你一个矩阵,让你找最大的矩形面积,F代表3,R代表 0,。 输入用%s 输入 #include #include #include #include #define maxn 1010 using namespace std; int ma[maxn][maxn]; int h[maxn]; int fact(int m) { int a,sum=0; stackq;

HLSHYR的博客 372

HDU 1505 City Game dp

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1505题意:给定一个n*m的矩阵,矩阵里每个点只有R和F两种,要求划分出一个只含有F的矩阵,求这个矩阵的最大面积思路:跟HDU1506很像,以矩阵的每一行作为底,把这一行之上的矩阵部分压缩为一维,就可以用1506的方法求了。#include <bits/stdc++.h> using namespace st

弱智就要多努力 432

HDU - 1505 City Game(dp)

题意:求由R和F组成的矩阵中,最大的由F组成的矩阵面积。 分析: 1、hdu1506http://www.cnblogs.com/tyty-Somnuspoppy/p/7341431.html与此题相似。 2、将矩阵的每行看成1506中的坐标轴分别处理。 3、算出以该行为坐标轴,坐标轴上,每个由F组成的矩形的高度,与1506的区别是,1506中每个矩形高度已知。 4、按照150...

Cherrychan2014的博客 141

HDU 1505 City Game(DP)

此题类似于HDU1505。       我们可将连续“F”看做是楼高,这样像1505题一样处理n层就可以了。复杂度O(nmlogm)。       #include #include #include #include #include #include #include #include #include #include #include #include usin

ACMiao的博客 444

hdu 1505 dp City Game

嗯。主要就是记录一行比a[i]的高度高的相邻的长度。然后比较面积最大的。 那么,怎么记录。。。 如果,a[i]左边第一个的高度比a[i]高,那么,搜寻比a[i-1]高的、、、依次类推。若果,a[i-1] 而当到a[i+1]的时候,如果a[i+1] 同理,右边一样这样计算与a[i]相邻的长度。 这时候,就用到了DP的思想。即所有的计算不会重复。计算过一遍之后,记录起来,用的时候,直接拿出来

夜月 561

hdu 1505 City Game(DP)

City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4646    Accepted Submission(s): 1976 Problem Description Bob is a strateg

ACway的专栏 3791

HDU 1505 动态规划(DP) City Game

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1505 分析; [HDU 1506的深化版]每输入一行,更新一次高度,就变成了1505题的问题了.[本题深化版HDU 2870] #include #include #include #include #include #include using namespace std; int

PWZER 876

HDU-1505 City Game (线性dp)

线性dp,跳跃转移。1000*1000个网格只包含R,F,求面积最大的只包含F的矩阵面积。

hmc0411的博客 677
上一篇: HDU 1159 Common Subsequence(DP,LCS)
下一篇: HDU 1856 More is better (数据结构,并查集)
fcbruce
博客等级 码龄13年 40粉丝 118原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值