HDU 1505 City Game (hdu1506 dp二维加强版)
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
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
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
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
#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二维加强版)的更多相关文章
- HDU 1505 City Game【DP】
题意:是二维的1506,即在1506的基础上,再加一个for循环,即从第一行到最后一行再扫一遍--- 自己写的时候,输入的方法不对---发现输不出结果,后来看了别人的----@_@发现是将字母和空格当 ...
- hdu 1505 City Game (hdu1506加强版)
# include <stdio.h> # include <algorithm> # include <string.h> # include <iostr ...
- HDU 1505 City Game(DP)
City Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- HDU 2159 FATE (DP 二维费用背包)
题目链接 题意 : 中文题不详述. 思路 : 二维背包,dp[i][h]表示当前忍耐值为i的情况下,杀了h个怪得到的最大经验值,状态转移方程: dp[i][h] = max(dp[i][h],dp[i ...
- 经典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] ...
- hdu6078 Wavel Sequence dp+二维树状数组
//#pragma comment(linker, "/STACK:102400000,102400000") /** 题目:hdu6078 Wavel Sequence 链接:h ...
- HDU 2888:Check Corners(二维RMQ)
http://acm.hdu.edu.cn/showproblem.php?pid=2888 题意:给出一个n*m的矩阵,还有q个询问,对于每个询问有一对(x1,y1)和(x2,y2),求这个子矩阵中 ...
- dp --- 二维dp + 最大上升子序列
<传送门> 滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 74477 Accepted: 27574 ...
- codeforces 597div2 F. Daniel and Spring Cleaning(数位dp+二维容斥)
题目链接:https://codeforces.com/contest/1245/problem/F 题意:给定一个区间(L,R),a.b两个数都是属于区间内的数,求满足 a + b = a ^ b ...
随机推荐
- 18.C#扩展方法(十章10.1-10.2)
今天的话题,我们来聊下扩展方法,自己也真心感叹自己的文笔,那叫一个惨啊,回顾写的文章,看着看着也忘记当时是怀着什么心态写的,哈哈,现代人真心是太随性了,可能也是太冷漠了,接着写的吧,总是会有帮助,也会 ...
- overlay-3
if(typeof Shadowbox=="undefined"){ throw"Unable to load Shadowbox, no base library ad ...
- hdu1305 字典树
这题我开始想的简单了,WA一次,然后看disscuss里有人说输入时长度从小到大的,然后我信了.然后开始while(1) WA;然后我尝试先放如数组.后来对了: discuss里面果然不能太相信. 根 ...
- 7.Android之评分条RatingBar和拖动条SeekBar学习
评分条RatingBar和拖动条SeekBar很常见,今天来学习下. (1)RatingBar评分条 如图: <RelativeLayout xmlns:android="http:/ ...
- Beta版本——冲刺计划及安排
我说的都队 031402304 陈燊 031402342 许玲玲 031402337 胡心颖 03140241 王婷婷 031402203 陈齐民 031402209 黄伟炜 031402233 郑扬 ...
- ajax入门详解
l 一个实例 在开始正式讲解 Ajax之前,首先让我们先来看看Google Map使用Ajax改善其产品设计的效果. 1. 在浏览器地址栏中输入http://maps.google.com打开Goog ...
- String类的常用方法
package stringUse; public class StringUse { public static void main(String[] args) { //获取 //indexOf, ...
- Java初学(四)
一.图解二维数组 二.图解动态创建二维数组 三.杨辉三角练习: import java.util.Scanner; class Array2Demo{ //实现杨辉三角 public static v ...
- 初学Hibernate主键生成策略
具有业务含义的主键叫自然主键:随机生成,不具备业务含义的字段作为主键,叫代理主键. 在表与POJO类关系映射文件XXX.hbm.xml中,可通过配置id元素下generator节点的class属性指定 ...
- https://github.com/yrs244742688/GeneratePemWithMoAndEx RSA加密
<RSAKeyValue> <Modulus> xA7SEU+e0yQH5rm9kbCDN9o3aPIo7HbP7tX6WOocLZAtNfyxSZDU16ksL6 Wjuba ...