City Game

hdu1505:http://acm.hdu.edu.cn/showproblem.php?pid=1505

题解:给你一个字符矩阵,里面有R和F两种字符,然后让你找一个最大的子矩阵,这个最大的子矩阵只含有F。

题解:在队友的提示下和上一题的影响,我先处理出每一行,以该行为起点的连续F的高度,然后每一行的情况问题就转化成上一题的问题,然后枚举每一行就可以了。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 const int N=1002;
 7 int n,m;
 8 char mp[N][N];
 9 int dp[N][N];
10 int ll[N],rr[N],ans;
11 int main(){
12   int cas;
13   scanf("%d",&cas);
14   while(cas--){
15     scanf("%d%d",&n,&m);
16     for(int i=1;i<=n;i++)
17         for(int j=1;j<=m;j++)
18           cin>>mp[i][j];
19     for(int i=1;i<=m;i++){
20             int temp=0;
21         for(int j=1;j<=n;j++){
22             if(mp[j][i]==‘F‘)
23                ++temp;
24             else
25                temp=0;
26             dp[j][i]=temp;
27         }
28     }
29       ans=0;
30        for(int i=n;i>=1;i--){
31         memset(ll,0,sizeof(ll));
32         memset(rr,0,sizeof(rr));
33         dp[i][0]=-1;dp[i][m+1]=-1;
34         for(int j=1;j<=m;j++){
35             ll[j]=j;
36             if(j==1)continue;
37             int t=j-1;
38           while(dp[i][j]<=dp[i][t]){
39              ll[j]=ll[t];
40              t=ll[t]-1;
41           }
42         }
43          for(int j=m;j>=1;j--){
44             rr[j]=j;
45             if(j==m)continue;
46             int t=j+1;
47           while(dp[i][j]<=dp[i][t]){
48              rr[j]=rr[t];
49              t=rr[t]+1;
50           }
51         }
52        for(int k=1;k<=m;k++){
53         ans=max(ans,(rr[k]-ll[k]+1)*dp[i][k]);
54        }
55       }
56    printf("%d\n",ans*3);
57   }
58
59 }

City Game

时间: 2024-10-09 07:43:39

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