#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. 第五周总结 & 实验报告(三)

    第五周总结 一.继承       1.类的继承格式 class 父类{} class 子类 extends 父类{} 2.扩展类的功能 class 父类{ 父类属性: .......... ..... ...

  2. Electron-Vue工程初始化,以及需要掌握的相关知识

    1.安装nodejs 下载地址:http://nodejs.cn/ 需要重启系统 2.安装electron npm install electron -g 3.安装vue npm install vu ...

  3. 获取免费的https证书

    可以通过网站获取免费的https证书 首先到https://freessl.org注册一个账号 然后就可以开始创建免费证书了 获取的证书里面通常只有pem后缀文件 nodejs使用的时候需要crt文件 ...

  4. qemu-kvm: unable to map backing store for guest RAM: Cannot allocate memory

    当给 KVM 虚拟机设置 hugepage 时,需要在虚拟机的配置文件里加上下面一段: <memoryBacking> <hugepages/></memoryBacki ...

  5. String 部分源码分析

    String 无参数构造函数 /** * 底层存储字符串的目标字节数组, * Jdk 8 之前都是字符数组 private final char[] value; */ @Stable private ...

  6. spark 怎么去连接 ElasticSearch

    https://stackoverflow.com/questions/52659109/cannot-read-from-elasticsearch-using-pyspark https://st ...

  7. 【Qt开发】将内存图像数据封装成QImage V2

    如何将内存图像数据封装成QImage 当采用Qt开发相机数据采集软件时,势必会遇到采集内存图像并进行处理(如缩放.旋转)操作.如果能够将内存图像数据封装成QImage,则可以利用QImage强大的图像 ...

  8. 实验报告5&第七周课程总结

    实验四 类的继承 实验目的 理解抽象类与接口的使用: 了解包的作用,掌握包的设计方法. 实验要求 掌握使用抽象类的方法. 掌握使用系统接口的技术和创建自定义接口的方法. 了解 Java 系统包的结构. ...

  9. js Functor Copy

    原文地址:https://segmentfault.com/a/1190000006051586?utm_source=tuicool&utm_medium=referral 本处仅仅个人存档 ...

  10. [AGC040B]Two Contests

    Description 给出若干条线段 \((L[i], R[i])\) ,把他们分成两个非空的集合,最大化集合内线段交的和. \(n\le 10 ^ 5\) Solution 考虑最小的一个右端点 ...