enhanced version of 1506City GameTime
limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 5587 Accepted Submission (s): 2412
Problem Descriptionbob is a strategy game programming specialist. In He new city building game the gaming environment was as Follows:a City was built up by areas, in which there was street S, trees,factories and buildings. There is still some space in the area it is unoccupied. The strategic task of his game was to win as much rent money from these free spaces. To win rent-must erect buildings, that can is only being rectangular, as long and wide as you can. Bob is trying to find a by-build the biggest possible building in each area. But he comes across some problems–he isn't allowed to destroy already existing buildings, trees, factories and streets In the area he's building in.
Each of the area have its width and length. The area was divided into a grid of equal square units. The rent paid for each unit on which you ' re building stands are 3$.
Your task is to help Bob solve this problem. The whole city was divided into K areas. Each one of the areas is rectangular and have a different grid size with its own length M and width n.the existing occupied Units is marked with the symbol R. The unoccupied units is marked with the symbol F.
Inputthe 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 both Integers-area length m<=1000 and width n&l t;=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 is:
r–reserved Unit
F–free Unit
The end of each area description there are a separating line.
Outputfor each data set with the input print on a separate line with the standard output, the integer that represents the pro Fit obtained by erecting the largest building, the area encoded by the data set.
Sample Input
6R F F f F FF F f f f FR R R F F ff F 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
Sample Output
450
Sourcesoutheastern Europe 2004
Recommendzl | 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;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Hdoj-1505-city Game "Dynamic planning" 1506 's enhanced version