HDU 1505 City Game (最大子矩形面积)
来源:互联网 发布:ibm云计算 编辑:程序博客网 时间:2024/04/30 09:18
题目链接: 轻点我一下 >3<
本题和 HDU1506 很像 不过本题要对前i行求最大子矩形面积 进而可得最大子矩形面积 - - 需要注意的是关于高度的读入 要仔细想一想
不要忘记每次清零h高度数组
AC代码如下:
//// HDU 1505 City Game//// Created by TaoSama on 2015-02-07// Copyright (c) 2014 TaoSama. All rights reserved.//#include <algorithm>#include <cctype>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iomanip>#include <iostream>#include <map>#include <queue>#include <string>#include <set>#include <vector>#define CLR(x,y) memset(x, y, sizeof(x))using namespace std;const int INF = 0x3f3f3f3f;const int MOD = 1e9 + 7;const int N = 1e5 + 10;int l[1005], r[1005], h[1005];char a[5];int main() {#ifdef LOCALfreopen("in.txt", "r", stdin);//freopen("out.txt","w",stdout);#endifios_base::sync_with_stdio(0);int k; cin >> k;while(k--) {int n, m; cin >> n >> m;int ans = -INF;CLR(h, 0); h[0] = h[m + 1] = -1;for(int i = 1; i <= n; ++i) {for(int j = 1; j <= m; ++j) {cin >> a;if(a[0] == 'F') ++h[j];else h[j] = 0;}for(int j = 1; j <= m; ++j)l[j] = r[j] = j;for(int j = 1; j <= m; ++j)while(h[l[j] - 1] >= h[j])l[j] = l[l[j] - 1];for(int j = m; j >= 1; --j)while(h[r[j] + 1] >= h[j])r[j] = r[r[j] + 1];for(int j = 1; j <= m; ++j)ans = max(ans, (r[j] - l[j] + 1) * h[j]);}cout << ans * 3 << endl;}return 0;}
0 0
- HDU 1505 City Game (最大子矩形面积)
- hdu 1505 City Game 最大矩形面积 单调队列
- HDU 1505 City Game (单调栈+最大子矩阵面积)
- 暑期dp46道(9)——HDU 1505City Game 求最大子矩阵面积
- City Game - HDU 1505 最大内部矩形
- Hdu 1505 City Game (DP求最大面积)
- HDU 1505 City Game-dp-(最大子矩阵模型)
- hdu 1505 City Game(最大子矩阵)
- hdu1505 City Game (最大子矩形)
- hdu 1505 City Game 简单DP 最大子矩阵 迭代法
- City Game(DP,最大矩形问题)
- UVALive 3029 City Game 悬线法求最大子矩阵面积 dp
- HDU 2870 Largest Submatrix (最大子矩形面积)
- hdu 1505 City Game(0和1 中的最大子矩阵)
- HDU 1505 City Game(DP求二维最大子矩阵)
- POJ 1964&HDU 1505&HOJ 1644 City Game(最大0,1子矩阵和总结)
- POJ1964/UVALive 3029 -City Game -求最大子矩形-(暴力枚举/dp)
- 【最大子矩形】面积
- python *args **kwargs
- c语言二维数组与指针(课时4)
- hibernate学习:一对一单向外键映射
- 定时器setTimeout的应用---延时提示框
- Oracle使用游标为所有用户表添加主键语句
- HDU 1505 City Game (最大子矩形面积)
- 矩阵顺时针旋转90°、180°、270°
- YouCompleteMe的安装
- 技术宅必读!科幻经典!“蒸汽朋克”圣经!人类的命运,将在术狂飙中走向何方?
- hibernate学习:一对一双向外键关联
- 件和规哦IPUIYui突然热让他维特认为
- JSON学习笔记
- Git配置SSH,并Push到GitHub上的相关流程
- pm_notifier 接收待机事件