hdoj-1505-City Game【动态规划】1506的加强版
来源:互联网 发布:小学生绘画软件下载 编辑:程序博客网 时间:2024/05/01 00:35
1506的加强版
City Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5587 Accepted Submission(s): 2412
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.
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.
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
25 6R F F F F FF F F F F FR R R F F FF F F F F FF F F F F F5 5R R R R RR R R R RR R R R RR R R R RR R R R R
Sample Output
450
Source
Southeastern Europe 2004
Recommend
zl | We have carefully selected several similar problems for you:1506 2870 1058 2830 2159
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;char map[1100][1100];int dp[1100][1100];int r[1100],l[1100];int main(){int t;scanf("%d",&t);while(t--){int n,m,i,j;char s;scanf("%d%d",&n,&m);for(i=1;i<=n;++i){for(j=1;j<=m;++j){while(scanf("%c",&s),!(s>='R'||s=='F'));map[i][j]=s;}}memset(dp,0,sizeof(dp)) ;//for(i=0;i<=n;++i) map[i][0]='R';//for(j=0;j<=m;++j) map[0][j]='R';for(i=1;i<=n;++i){for(j=1;j<=m;++j){if(map[i][j]=='F'){dp[i][j]=dp[i-1][j]+1;}else dp[i][j]=0;}}int maxn=0; for(i=1;i<=n;++i){ r[m+1]=0;l[0]=0; dp[i][0]=-1;dp[i][m+1]=-1; for(j=1;j<=m;++j){ l[j]=j; while(dp[i][l[j]-1]>=dp[i][j]) l[j]=l[l[j]-1]; } for(j=m;j>=1;--j){ r[j]=j; while(dp[i][r[j]+1]>=dp[i][j]) r[j]=r[r[j]+1]; } for(j=1;j<=m;++j){ maxn=max(maxn,(r[j]-l[j]+1)*dp[i][j]); } } printf("%d\n",maxn*3);}return 0;}
0 0
- hdoj-1505-City Game【动态规划】1506的加强版
- HDU1505--City Game(动态规划)(1506加强版)
- HDOJ题目1505 City Game(动态规划)
- hdu1505—City Game(1506的加强版)
- HDU 1505 动态规划(DP) City Game
- hdu 1505 City Game (动态规划)
- hdu 1505 city game(1506加强版)dp
- hdu 1505 City Game (hdu1506加强版)
- [HDU 1505 City Game] HDU1506加强版
- HDOJ 1505 City Game
- hdoj 1506&&1505(City Game) dp
- HDU 1505(City Game)动态规划-最大矩阵
- HDU 1505 Largest Rectangle in a Histogram && HDU 1506 City Game(动态规划)
- HDOJ 1505 City Game
- HDOJ 1505 City Game (单调栈)
- hdu 1505 City Game (hdu 1506的升级版)
- hdu 1505 City Game 1506的二维
- HDU1505 City Game (DP,HDU1506加强版)
- hdu1312 Red and Black(入门dfs)
- CSS3动画实现loading加载图标
- USACO 2.1.3 Sorting A Three-Valued Sequence
- hihoCoder 1093 最短路径·三:SPFA算法
- 二分查找算法
- hdoj-1505-City Game【动态规划】1506的加强版
- [基本实验] 远程桌面攻击
- 飞鸽传书源码分析六-文件传输续
- 为什么中断handler中不能休眠
- Kubernetes技术分析之存储
- close 和shutdown 函数
- 着色问题
- C++中的多态
- 《编程思想-笔记》-第三章,第四章