#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double EPS = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 2e5 + ;
const int maxm = ;
//next_permutation
//priority_queue<int, vector<int>, greater<int>> que;
int n, m;
int num[][];
int r[][], l[][];
void pf()
{
cout<<endl;
for (int i = ; i <= n; i++)
{
for (int j = ; j <= m; j++)
{
cout << num[i][j] << " ";
}
cout << endl;
}
cout<<endl;
for (int i = ; i <= n; i++)
{
for (int j = ; j <= m; j++)
{
cout << l[i][j] << " ";
}
cout << endl;
}
cout<<endl;
for (int i = ; i <= n; i++)
{
for (int j = ; j <= m; j++)
{
cout << r[i][j] << " ";
}
cout << endl;
}
}
char a[];
int main()
{
//freopen("bonuses.in", "r", stdin);
//freopen("out.txt", "w", stdout);
int t;
cin >> t;
while (t--)
{
int ans = ;
cin >> n >> m;
for (int i = ; i <= n; i++)
for (int j = ; j <= m; j++)
{
scanf("%s", a);
num[i][j] = a[] == 'R' ? : (num[i - ][j] + );
}
//pf();
int lenr, lenc;
for (int i = ; i <= n; i++)
for (int j = ; j <= m; j++)
{
l[i][j] = r[i][j] = j;
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= m; j++)
{
int cur = j;
while (cur != && num[i][cur-] >= num[i][j])
{
cur = l[i][cur - ];
}
l[i][j] = cur;
}
for (int j = m; j >= ; j--)
{
int cnt = j;
while (cnt != m && num[i][cnt+] >= num[i][j])
{
cnt = r[i][cnt + ];
}
r[i][j] = cnt;
}
for(int j=;j<=m;j++)
ans = max(ans, (r[i][j] - l[i][j] + ) * num[i][j] * );
}
//pf();
cout << ans << endl;
} }

hdu 1505 单调栈升级版的更多相关文章

  1. hdu 1506 单调栈问题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1506 题目的意思其实就是要找到一个尽可能大的矩形来完全覆盖这个矩形下的所有柱子,只能覆盖柱子,不能留空 ...

  2. hdu 5033 单调栈 ****

    看出来是单调栈维护斜率,但是不会写,2333,原来是和询问放在一起的 #include <iostream> #include <cstdio> #include <cs ...

  3. hdu 5875(单调栈)

    Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  4. HDU 5033 (单调栈维护凸包) Building

    题意: 一个人在x轴上,他的左右两侧都有高楼,给出楼的横坐标Xi和高度Hi还有人的位置pos,求人所能看到的天空的最大角度. 分析: 将建筑物和人的位置从左到右排序,对于每个位置利用栈求一次人左边建筑 ...

  5. hdu 4923 单调栈

    http://acm.hdu.edu.cn/showproblem.php?pid=4923 给定一个序列a,元素由0,1组成,求一个序列b,元素在0~1之间,并且保证递增.输出最小的∑(ai−bi) ...

  6. hdu 3410 单调栈

    http://acm.hdu.edu.cn/showproblem.php?pid=3410 Passing the Message Time Limit: 2000/1000 MS (Java/Ot ...

  7. hdu 1506 单调栈

    #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #defin ...

  8. HDU 5033 Building(单调栈)

    HDU 5033 Building(单调栈) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5033 Description Once upon a ti ...

  9. 【单调栈】hdu 6319 杭电多校Problem A. Ascending Rating

    http://acm.hdu.edu.cn/showproblem.php?pid=6319 从后往前更新,维护一个递减单调栈(队列) 最近很多题都是单调栈... #define _CRT_SECUR ...

随机推荐

  1. 使用collection:分段查询结果集

    1.在人员接口书写方法 public List<Employee> getEmpsByDeptId(Integer deptId); 2在人员映射文件中进行配置 <!-- publi ...

  2. HTTP缓存初识

    一.HTTP缓存 1.强制缓存 2.协商缓存 静态资源 动态资源 二.总结 参考: http://muchstudy.com/2016/08/18/HTTP%E7%BC%93%E5%AD%98%E8% ...

  3. UI-WPF_UI:WPF UI - DMSkin官方网站

    ylbtech-UI-WPF_UI:WPF UI - DMSkin官方网站 1.返回顶部 1. QQ: 944095635 DMSkin.com 首页 论坛 定制 博客  联系   DMSkin 3. ...

  4. Selenium IDE安装及环境搭建教程

    摘自https://blog.csdn.net/ywyxb/article/details/59103683 Selenium IDE环境部署- Firefox浏览器Firefox-ESR版本下载(推 ...

  5. Ubuntu C/C++的编译环境

    Ubuntu缺省情况下,并没有提供C/C++的编译环境,因此还需要手动安装.但是如果单独安装gcc以及g++比较麻烦,幸运的是,Ubuntu提供了一个build-essential软件包.查看该软件包 ...

  6. windows一次无线网卡被关闭事件

    使用的是Dell的笔记本,fn+无线图标莫名的是蓝牙的启动. 有一天突然无线网卡无法上网,无法发现无线网络: 1. 在服务中开启"Wired AutoConfig"以及“WLAN ...

  7. 6.824 Lab 2: Raft 2B

    Part 2B We want Raft to keep a consistent, replicated log of operations. A call to Start() at the le ...

  8. [ScreenOS] How to change the certificate that is used for SSL (HTTPS) WebUI Management

    SUMMARY: This article provides information on how to change the certificate that is used for SSL (HT ...

  9. 操作系统(1)——X86-32硬件介绍、实验环境相关配置、uCore部分技巧介绍

    实验环境 本文假设已经创建虚拟机并配置好Ubuntu 16.04(网上太多教程了,所以这里就不赘述了). X86-32硬件介绍 x86指的是80386这种机器(一种32位CPU,在早期得到了广泛的应用 ...

  10. 第9周总结&实验报告7

    完成火车站售票程序的模拟. 要求:(1)总票数1000张:(2)10个窗口同时开始卖票:(3)卖票过程延时1秒钟:(4)不能出现一票多卖或卖出负数号票的情况.一:实验代码 package first; ...