F - City Game

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Appoint description:

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
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int d[][];
int l[];
int r[];
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b;
cin>>a>>b;
// memset(d,0,sizeof(d));
for(int i=; i<a; i++)
{
for(int j=; j<b; j++)
{
char c[];
cin>>c;
if(c[]=='F')
d[i][j]=;
else
d[i][j]=;
}
}
/*
0 1 1 1 1 1 0 1 1 1 1 1
1 1 1 1 1 1 (F=1,R=0,方便求和) 1 2 2 2 2 2
0 0 0 1 1 1 转化完就是右边矩阵 0 0 0 3 3 3
1 1 1 1 1 1 1 1 1 4 4 4
1 1 1 1 1 1 2 2 2 5 5 5
*/
for(int i=; i<a; i++)
{
for(int j=; j<b; j++)
{
if(d[i][j]!=)
d[i][j]=d[i-][j]+;
}
}
/* printf("--------------->\n");
for(int i=0; i<a; i++){
for(int j=0; j<b; j++)
printf("%d ",d[i][j]);
printf("\n");
} printf("----------------->\n");*/
int max=;
for(int i=; i<a; i++){
for(int j=; j<b; j++){
l[j]=j;
while(l[j]>&&d[i][l[j]-]>=d[i][j])
l[j]=l[l[j]-];
}
for(int j=b-; j>-; j--){
r[j]=j;
while(r[j]<b-&&d[i][r[j]+]>=d[i][j])
r[j]=r[r[j]+];
}
for(int j=; j<b; j++)
if(max<((r[j]-l[j]+)*d[i][j]))
max=((r[j]-l[j]+)*d[i][j]);
}
cout<<max*<<endl;
}
return ;
}

HDU 1505 City Game (hdu1506 dp二维加强版)的更多相关文章

  1. HDU 1505 City Game【DP】

    题意:是二维的1506,即在1506的基础上,再加一个for循环,即从第一行到最后一行再扫一遍--- 自己写的时候,输入的方法不对---发现输不出结果,后来看了别人的----@_@发现是将字母和空格当 ...

  2. hdu 1505 City Game (hdu1506加强版)

    # include <stdio.h> # include <algorithm> # include <string.h> # include <iostr ...

  3. HDU 1505 City Game(DP)

    City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  4. HDU 2159 FATE (DP 二维费用背包)

    题目链接 题意 : 中文题不详述. 思路 : 二维背包,dp[i][h]表示当前忍耐值为i的情况下,杀了h个怪得到的最大经验值,状态转移方程: dp[i][h] = max(dp[i][h],dp[i ...

  5. 经典DP 二维换一维

    HDU 1024  Max Sum Plus Plus // dp[i][j] = max(dp[i][j-1], dp[i-1][t]) + num[j] // pre[j-1] 存放dp[i-1] ...

  6. hdu6078 Wavel Sequence dp+二维树状数组

    //#pragma comment(linker, "/STACK:102400000,102400000") /** 题目:hdu6078 Wavel Sequence 链接:h ...

  7. HDU 2888:Check Corners(二维RMQ)

    http://acm.hdu.edu.cn/showproblem.php?pid=2888 题意:给出一个n*m的矩阵,还有q个询问,对于每个询问有一对(x1,y1)和(x2,y2),求这个子矩阵中 ...

  8. dp --- 二维dp + 最大上升子序列

    <传送门> 滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 74477   Accepted: 27574 ...

  9. codeforces 597div2 F. Daniel and Spring Cleaning(数位dp+二维容斥)

    题目链接:https://codeforces.com/contest/1245/problem/F 题意:给定一个区间(L,R),a.b两个数都是属于区间内的数,求满足 a + b = a ^ b ...

随机推荐

  1. 2016 版 Laravel 系列入门教程(一)【最适合中国人的 Laravel 教程】

    本教程示例代码见: https://github.com/johnlui/Learn-Laravel-5 在任何地方卡住,最快的办法就是去看示例代码. 本文基于 Laravel 5.2 版本,无奈 5 ...

  2. Daily Scrum – 1/11

    Meeting Minutes 发现了一个新的bug,即当背诵单词过多时,会出现统计信息超出文字框的现象: 更新了tfs,明白了打包的方式: Burndown     Progress   part ...

  3. 拦路虎:jQuery

    1.   color设置无效的问题! $("#subscribe").hover(function(){ var $this = $("#subscribe .subsc ...

  4. 【POJ 2104】 K-th Number 主席树模板题

    达神主席树讲解传送门:http://blog.csdn.net/dad3zz/article/details/50638026 2016-02-23:真的是模板题诶,主席树模板水过.今天新校网不好,没 ...

  5. TS

    //html文件 <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...

  6. Lucene 4.7 --创建索引

    Lucene的最新版本和以前的语法或者类名,类规定都相差甚远 0.准备工作: 1). Lucene官方API http://lucene.apache.org/core/4_7_0/index.htm ...

  7. BZOJ-2324 营救皮卡丘 最小费用可行流+拆下界+Floyd预处理

    准备一周多的期末,各种爆炸,回来后状态下滑巨快...调了一晚上+80%下午 2324: [ZJOI2011]营救皮卡丘 Time Limit: 10 Sec Memory Limit: 256 MB ...

  8. 装了虚拟机,但是没有虚拟网卡vmnet0 vmnet1 vmnet8

    在服务里面启动图中的两个服务,在再你的虚拟网络编辑器里面点恢复默认设置就会出现了,我的是win8.1,默认这两个服务是手动启动的,可能是优化软件优化的结果 我是win10  里面显示以太网3 和 4, ...

  9. 【poj2773】 Happy 2006

    http://poj.org/problem?id=2773 (题目链接) 题意 给出两个数m,k,要求求出从1开始与m互质的第k个数. Solution 数据范围很大,直接模拟显然是不行的,我们需要 ...

  10. codeforces 719A:Vitya in the Countryside

    Description Every summer Vitya comes to visit his grandmother in the countryside. This summer, he go ...