City Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4823 Accepted Submission(s): 2064
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
和150差不多,只不过是增加了一维,输入的时候要处理出当前横向上能取的高度(级当前行上面有几个F)
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int n,m;
int mp[1001][1001];
int l[1001],r[1001];
char c;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t;
cin>>t;
while(t--)
{
cle(mp);
scanf("%d%d",&m,&n);
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
{
scanf("%s",&c);
if(c=='F')
mp[i][j]=mp[i-1][j]+1;
else if(c=='R') mp[i][j]=0;
}
int MAx=-INF,temp;
for(int i=1;i<=m;i++)
{
l[1]=1;
r[n]=n;
for(int j=2;j<=n;j++)
{
temp=j;
while(mp[i][temp-1]>mp[i][j]&&temp>1)//动态规划过程 滚动数组
{
temp=l[temp-1];
}
l[j]=temp;
}
for(int j=n-1;j>=1;j--)
{ temp=j;
while(mp[i][temp+1]>=mp[i][j]&&temp<n)
{
temp=r[temp+1];
}
r[j]=temp;
}
int Max=-1;
for(int j=1;j<=n;j++)
Max=max(Max,(r[j]-l[j]+1)*mp[i][j]);
MAx=max(Max,MAx);
}
cout<<MAx*3<<endl;
}
return 0;
}