http://acm.hdu.edu.cn/showproblem.php?pid=1505
City Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3929 Accepted Submission(s): 1637
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.
R – reserved unit
F – free unit
In the end of each area description there is a separating line.
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
45 0
(这游戏是大富翁?)圈一个最大的矩形,F可圈,R不可,HDU1506的高级版(1506链接:http://acm.hdu.edu.cn/showproblem.php?pid=1506,解题报告:http://blog.csdn.net/u012965890/article/details/19646851)每一行都当做1506中的X轴更新直方图高度,R就是0
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<cctype>
#include<cmath>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#define sqr(x) (x)*(x)
#define INF 0x1f1f1f1f
#define PI 3.1415926535
#define LL long long
#define mm 1001
using namespace std;
int l[mm],r[mm],up[mm],map[mm][mm];
int n,m;
int area,maxarea;
char s[10];
void solve(int x)
{
int i,j;
for (i=1;i<m;i++)
{
while(l[i]-1>=0 && map[x][l[i]-1]>=map[x][i])
{
l[i]=l[l[i]-1];
}
}
for (i=m-2;i>=0;i--)
{
while (r[i]+1<m && map[x][r[i]+1]>=map[x][i])
{
r[i]=r[r[i]+1];
}
}
for (i=0;i<m;i++)
{
maxarea=max(maxarea,map[x][i]*(r[i]-l[i]+1));
}
}
int main()
{
int tt;
scanf("%d",&tt);
while(tt--)
{
scanf("%d%d",&n,&m);getchar();
maxarea=0;
memset(map,0,sizeof(map));
for (int i=1;i<=n;i++)
{
for (int j=0;j<m;j++)
{
scanf("%s",s);
if (s[0]=='F')
map[i][j]=map[i-1][j]+1;
l[j]=r[j]=j;
}
solve(i);
}
printf("%d\n",maxarea*3);
}
return 0;
}
1万+




被折叠的 条评论
为什么被折叠?



