| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 593 人关注过本帖
标题:杭电的1505最大矩形问题题,我怎么AC不过啊!!
只看楼主 加入收藏
好孩子好宝贝
Rank: 1
等 级:新手上路
帖 子:35
专家分:2
注 册:2011-7-26
结帖率:87.5%
收藏
已结贴  问题点数:10 回复次数:5 
杭电的1505最大矩形问题题,我怎么AC不过啊!!
City Game
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1667    Accepted Submission(s): 645


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.

 

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.

 

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
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
45
0


[ 本帖最后由 好孩子好宝贝 于 2011-8-9 05:05 编辑 ]
搜索更多相关主题的帖子: game strategic building Memory gaming 
2011-08-08 20:50
好孩子好宝贝
Rank: 1
等 级:新手上路
帖 子:35
专家分:2
注 册:2011-7-26
收藏
得分:0 
我的代码:

#include<stdio.h>
#include<string.h>
#define T 1010
double map[T][T],max;
int R,M,N,r[T],l[T];

void make_set()
{
    int i;
    for(i=0;i<=N+1;i++)
    {
        l[i]=i;
        r[i]=i;
    }
}
int main()
{
    int i,j;
    char t;
    scanf("%d",&R);
    while(R--)
    {
        scanf("%d%d",&N,&M);
        memset(map,0,sizeof(map));
        t=getchar();                      //接受回车。
        for(i=1;i<=N;i++)
        {
            for(j=1;j<=M;j++)
            {
                scanf("%c",&t);
                if(t=='F') map[i][j]=map[i][j-1]+1;
                t=getchar();             //接受空格和回车。
            }
        }
        max=0;
        for(i=1;i<=M;i++)
        {   
            make_set();
            for(j=1;j<=N;j++)
                while( map[j][i]!=0 && map[l[j]-1][i]>=map[j][i])
                    l[j]=l[l[j]-1];
            for(j=N;j>=1;j--)
                while( map[j][i]!=0 && map[r[j]+1][i]>=map[j][i] )
                    r[j]=r[r[j]+1];
            for(j=1;j<=N;j++)
                max=max>map[j][i]*(r[j]-l[j]+1)?max:map[j][i]*(r[j]-l[j]+1);
        }
        printf("%.0lf\n",3*max);
    }
    return 0;
}
2011-08-08 20:50
obstratiker
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:1
帖 子:198
专家分:758
注 册:2011-5-5
收藏
得分:10 
我试了这段代码结果是对的,就是不知道提交时对不对了

#include <stdio.h>

void fun(int k)
{
    int i,j,c,m,n;
    int value[k];
    for(c=0;c<k;c++)
    {
        scanf("%d%d",&m,&n);
        char a[m][n];
        for(i=0;i<m;i++)
            scanf("%s",a[i]);
        printf("\n");
        value[c]=find(a,m,n);
    }
    for(c=0;c<k;c++)
        printf("%d\n",value[c]);
}

int find(char (*p)[],int m,int n)
{
    int i,j,c,d;
    int max=0,count=0;
    for(i=0;i<m;i++)
        for(j=0;j<n;j++)
        {
            c=i;d=j;
            count=0;
            while(*(*p+c*n+d)!='r' && c<m)
            {
                if(d==n-1)
                {
                    c++;
                    d=j;
                }
                else
                    d++;
                count++;
            }
            if(count>max)
                max=count;
        }
    return 3*max;
}

int main(void)
{
    int n;
    scanf("%d",&n);
    fun(n);
}
2011-08-10 00:26
好孩子好宝贝
Rank: 1
等 级:新手上路
帖 子:35
专家分:2
注 册:2011-7-26
收藏
得分:0 
???我的代码哪儿错啦嘛?我的也就是过不了
自己的测试都可以。。。。
2011-08-12 00:22
obstratiker
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:1
帖 子:198
专家分:758
注 册:2011-5-5
收藏
得分:0 
回复 4楼 好孩子好宝贝
我也不知道啊,本想看看的,但是我编译的你代码没通过,不知道是什么回事
2011-08-12 00:53
好孩子好宝贝
Rank: 1
等 级:新手上路
帖 子:35
专家分:2
注 册:2011-7-26
收藏
得分:0 
回复 3楼 obstratiker
能帮我找找我的错误码?
2011-08-13 19:25
快速回复:杭电的1505最大矩形问题题,我怎么AC不过啊!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028992 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved