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 file 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 file 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

悬线法典型例题。

//up[i][j]表示矩形高度为up[i][j]  left[i][j]表示最左边能到坐标left[i][j]  right[i][j]表示最右边能到坐标right[i][j]

转移即可,注意细节

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) < 0 ? (-1 * (a)) : (a))
inline void swap(int &a, int &b)
{
int tmp = a;a = b;b = tmp;
}
inline void read(int &x)
{
x = ;char ch = getchar(), c = ch;
while(ch < '' || ch > '') c = ch, ch = getchar();
while(ch <= '' && ch >= '') x = x * + ch - '', ch = getchar();
if(c == '-') x = -x;
} const int INF = 0x3f3f3f3f;
const int MAXN = + ; int t,n,m,left[MAXN][MAXN],right[MAXN][MAXN],up[MAXN][MAXN],ans;
char s[MAXN][MAXN];
//up[i][j]表示矩形高度为up[i][j] left[i][j]表示最左边能到坐标left[i][j] right[i][j]表示最右边能到坐标right[i][j] int main()
{
read(t);
for(;t;--t)
{
read(n), read(m);
for(register int i = ;i <= n;++ i) for(register int j = ;j <= m;++ j) scanf("%s", &s[i][j]);
ans = ;
for(register int i = ;i <= n;++ i)
{
//左->右维护up和left
int lo = ;
for(register int j = ;j <= m;++ j)
{
if(s[i][j] == 'R') left[i][j] = up[i][j] = , lo = j;
else
{
left[i][j] = max(left[i - ][j], lo + );
up[i][j] = up[i - ][j] + ;
}
}
int ro = m + ;
for(register int j = m;j >= ;-- j)
{
if(s[i][j] == 'R') right[i][j] = n + , ro = j;
else right[i][j] = i == ? ro - : min(right[i - ][j], ro - );
ans = max(ans, (right[i][j] - left[i][j] + ) * up[i][j]);
}
}
printf("%d\n", ans * );
}
return ;
}

LA3029

LA3029 City Game的更多相关文章

  1. BZOJ 2001: [Hnoi2010]City 城市建设

    2001: [Hnoi2010]City 城市建设 Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 1132  Solved: 555[Submit][ ...

  2. History lives on in this distinguished Polish city II 2017/1/5

    原文 Some fresh air After your time underground,you can return to ground level or maybe even a little ...

  3. History lives on in this distinguished Polish city 2017/1/4

    原文 History lives on in this distinguished Polish city Though it may be ancient. KraKow, Poland, is a ...

  4. #1094 : Lost in the City

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi gets lost in the city. He does not know where he is ...

  5. GeoIP Legacy City数据库安装说明

    Here is a brief outline of the steps needed to install GeoIP Legacy City on Linux/Unix. The installa ...

  6. [POJ3277]City Horizon

    [POJ3277]City Horizon 试题描述 Farmer John has taken his cows on a trip to the city! As the sun sets, th ...

  7. 2015年第8本(英文第7本):the city of ember 微光城市

    书名:the City of Ember(中文名:微光城市) 作者:Jeanne DuPrau 单词数:6.2万 不重复单词数:未知 首万词不重复单词数:未知 蓝思值:未知 阅读时间:2015年4月2 ...

  8. 离散化+线段树 POJ 3277 City Horizon

    POJ 3277 City Horizon Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18466 Accepted: 507 ...

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

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

随机推荐

  1. <python基础>封装,继承,多态,重写,重载

    什么是封装? 所谓的面向对象就是将我们的程序模块化,对象化,把具体事物的特性属性和通过这些属性来实现一些动作的具体方法放到一个类里面,这就是封装.封装是我们所说的面相对象编程的特征之一.除此之外还有继 ...

  2. jmeter-测试https请求

    找了一个HTTPS请求的网站尝试. 我用的是chrome,点这个小锁(如果是IE也可以在网页上右键,属性,高级,证书) 或 看到下图,点击“复制到文件” 或 把导出的证书打成.store 用此命令进行 ...

  3. 【核心核心】10.Spring事务管理【TX】XML+注解方式

    转账案例环境搭建 1.引入JAR包 IOC的6个包 AOP的4个包 C3P0的1个包 MySQL的1个驱动包 JDBC的2个目标包 整合JUnit测试1个包 2.引入配置文件 log4j.proper ...

  4. C++: inheritance

    公有继承(public).私有继承(private).保护继承(protected)是常用的三种继承方式. 1. 公有继承(public) 公有继承的特点是基类的公有成员和保护成员作为派生类的成员时, ...

  5. cycloneii normal mode vs. arithmetic mode

    Combout = F(data1, data2, data3 or cin, data4) 在 arithmetic mode,只有 data1\data2 参加运算. 4-LUT到2个3-LUT的 ...

  6. thinkphp 动态查询

    借助PHP5语言的特性,ThinkPHP实现了动态查询,核心模型的动态查询方法包括下面几种: 方法名 说明 举例 getBy 根据字段的值查询数据 例如,getByName,getByEmail ge ...

  7. SpringBoot学习笔记(七):SpringBoot使用AOP统一处理请求日志、SpringBoot定时任务@Scheduled、SpringBoot异步调用Async、自定义参数

    SpringBoot使用AOP统一处理请求日志 这里就提到了我们Spring当中的AOP,也就是面向切面编程,今天我们使用AOP去对我们的所有请求进行一个统一处理.首先在pom.xml中引入我们需要的 ...

  8. Cesium官方教程11--建模人员必读

    原文地址:https://cesium.com/blog/2014/12/15/gltf-tips-for-artists/ 这篇文章是Branden Coker, an artist from AG ...

  9. PAT甲级——A1081 Rational Sum

    Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum. ...

  10. <每日一题>题目7:简单的学生管理系统V1.0

    ''' # 学生管理系统v1.0 # 添加学生的信息 # 删除学生的信息 # 修改学生的信息 # 查看学生的信息 #遍历学生的信息 #退出系统 ''' import json #1 显示操作功能 de ...