#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. tomcat简单性能优化

    1.内存使用配置 2.最大连接数配置

  2. mysql中查看ef或efcore生成的sql语句

    http://www.solves.com.cn/it/sjk/MYSQL/2019-07-01/1336.html 涉及命令 1.开启general log模式 MySQL>set globa ...

  3. Array Stack Implement using C

  4. Ubuntu - apt 下载源设置为阿里的源

    # 备份 sources.list cp /etc/apt/sources.list /etc/apt/sources.list.bak # 切换为阿里的源 echo "deb http:/ ...

  5. expression,statement,definition ,identifier(symbol) ,literal(字面量) 术语

    expression: an expression evaluates to a value only statement: a statement containing executable cod ...

  6. Appium关键字

    *** Settings *** Library AppiumLibrary Library AutoItLibrary Library os *** Keywords *** xpath应该匹配次数 ...

  7. Lesson 5 The facts

    go to extremes走极端 provide... with...向..提供.. go to press付印 suspicious,adj. 可疑的:怀疑的:多疑的 fired---同义词--- ...

  8. spark 怎么去连接 ElasticSearch

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

  9. python 封装dlib模型进行人脸识别系统的登录认证

    1.直接上干货 #!/usr/bin/python # -*- coding: utf-8 -*- import time import dlib import numpy as np class f ...

  10. 华南理工大学“三七互娱杯” D HRY and array

    https://ac.nowcoder.com/acm/contest/874/D 题目大意是给定两个数组A和B 数组的元素可以打乱重新排列 然后求∑ni=1 AiBi 的期望 我是这么理解的: 由于 ...