A - City Game

#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
#define N 1002
int map[N][N];
int main()
{
    int i,j,m,n,Min,area,high,t,k;
    char c[100];
    scanf("%d",&t);
    while(t--)
    {
        for(i=0; i<N; i++)
          for(j=0; j<N; j++)
                map[i][j]=0;
        //初始化全为0
        scanf("%d%d",&n,&m);
        area=0;
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=m; j++)
            {
                scanf("%s",&c); //可能有多个空格,%c的话就WA了
                if(c[0]==‘F‘)
                    map[i][j]=map[i][j-1]+1;
                else
                    map[i][j]=0;
            }   //输入一行,求一次最大面积
            for(j=1; j<=m; j++)
            {
                if(map[i][j]!=0)
                {
                    Min=map[i][j];       //记录这一列[i][j]的最小值
                    if(area<map[i][j])
                        area=map[i][j];   //此时这一行的面积即是[i][j]的值,应为[i][j]记录的就是F
                    high=1;  //高的初值应该为1(只有自身一行)
                    for(k=i-1; k>=1; k--) //向上查找
                    {
                        if(map[k][j]==0)  //遇到R就可以退出了
                            break;
                        else if(map[k][j]!=0)
                        {
                            high++;   //找到一个F,高度加1
                            if(map[k][j]<Min)   //更新这一列[i][j]的最小值
                                Min=map[k][j];
                            if(area<high*Min)  //计算面积并更新
                                area=high*Min;
                        }
                    }
                }
            }
        }
        printf("%d\n",area*3);
    }
    return 0;
}

http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=228#problem/A

A - City Game

时间: 2024-08-28 04:30:04

A - City Game的相关文章

City Upgrades

City Upgrades Time limit: 1000 msMemory limit: 128 MB There are N cities placed in a line. For each city ii you know its coodinate x??. You can upgrade exactly K of these cities. Your goal is to choose what cities to upgrade in a way the minimizes th

NYOJ 284 坦克大战 &amp;&amp; POJ 2312 Battle City (广搜+优先队列)

链接:click here~~ 题意: 描述 Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty space

Battle City BFS+优先队列

Battle City Many of us had played the game "Battle city" in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that consists of empty spaces, rivers,

UIPicker city.plist(实例)

前言: UIPickerView 是一个选择器控件, 它可以生成单列的选择器,也可生成多列的选择器,而且开发者完全可以自定义选择项的外观,因此用法非常灵活.UIPickerView 直接继承了 UIView ,没有继承 UIControl ,因此,它不能像 UIControl 那样绑定事件处理方法, UIPickerView 的事件处理由其委托对象完成. 正文: UIPickerView 控件常用的属性和方法如下:   numberOfComponents: 获取UIPickerView指定列中

City Game(动态规划)

City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5984    Accepted Submission(s): 2569 Problem Description Bob is a strategy game programming specialist. In his new city building game t

bzoj:1687;poj 2434:[Usaco2005 Open]Navigating the City 城市交通

Description A dip in the milk market has forced the cows to move to the city. The only employment available is in the venerable field of taxi-driving. Help the cows learn their way around the city. Given a city map with E (1 <= E <= 40) east/west st

HDU 1505 City Game (hdu1506 dp二维加强版)

F - City Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1505 Appoint description: Description Bob is a strategy game programming specialist. In his new city building game the gaming enviro

hdu 1505 City Game 最大矩形面积 单调队列

City Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5106    Accepted Submission(s): 2197 Problem Description Bob is a strategy game programming specialist. In his new city building game t

POJ 2312 Battle City(优先队列+BFS)

题目链接:http://poj.org/problem?id=2312 Battle City Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7085   Accepted: 2390 Description Many of us had played the game "Battle city" in our childhood, and some people (like me) even often pl

ZOJ 3211 Dream City (J) DP

Dream City Time Limit: 1 Second      Memory Limit: 32768 KB JAVAMAN is visiting Dream City and he sees a yard of gold coin trees. There are n trees in the yard. Let's call them tree 1, tree 2 ...and tree n. At the first day, each tree i has ai coins