#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. Sensor在内核中的驱动框架【转】

    本文转载自:http://blog.csdn.net/armfpga123/article/details/52840370 内核中对sensor的抽象:drivers/sensors/sensors ...

  2. WPF Knowledge Points - 默认视图(DefaultView),CollectionSourceView,CollectionView的区别

    这些天一直在做一些关于Treeview的事情,想写出来一些用法和心得.说到集合对象的显示和表现,CollectionSourceView和CollectionView有着至关重要的作用,所以在写Tre ...

  3. Object 的 property descriptor

    property descriptor 属性描述符: o = { get foo() { return 17; } }; d = Object.getOwnPropertyDescriptor(o, ...

  4. Linux监控命令之==>top

    一.命令说明 top 命令能够实时监控系统的运行状态,并且可以按照CPU.内存和执行时间进行排序,同时top 命令还可以通过交互式命令进行设定显示,通过top 命令可以查看即时活跃的进行. 二.参数说 ...

  5. django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.的解决办法

    如题,这个错误的解决办法如下: 在代码文件的最上方添加以下代码: import os,django os.environ.setdefault("DJANGO_SETTINGS_MODULE ...

  6. python string_3 end 内建函数详解

    以下方法,是在python2上运行的,编码也使用的是python2, 在对比python3后,发现,基本相同,也就是说在print后补上(),使用函数方式,是可以在python3下运行的, 删除了针对 ...

  7. word2vec (CBOW、分层softmax、负采样)

    本文介绍 wordvec的概念 语言模型训练的两种模型CBOW+skip gram word2vec 优化的两种方法:层次softmax+负采样 gensim word2vec默认用的模型和方法 未经 ...

  8. python 并发编程 多进程 互斥锁与join区别

    互斥锁与join 互斥锁和join都可以把并发变成串行 以下代码是用join实现串行 from multiprocessing import Process import time import js ...

  9. c++ 加载库错误问题解决

    转载自:http://blog.csdn.net/sahusoft/article/details/7388617 一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如: ...

  10. 指定pom文件jdk版本

    <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> ...