#P4147. 玉蟾宫

    ID: 4867 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>动态规划 DP枚举单调栈

玉蟾宫

Background

One day, the kittens rainbow and freda came to Yuchan Palace on Tianmen Mountain in Zhangjiajie, Western Hunan. The palace master, Blue Rabbit (Lan Tu), warmly entertained them and granted them a piece of land.

Problem Description

This piece of land is divided into N×MN\times M cells. Each cell contains R or F. R means the cell is granted to rainbow, and F means it is granted to freda.

Now freda wants to act cute here... She wants to find a rectangular piece of land that is all F, with the largest possible area.

But rainbow and freda are very weak at OI, and Blue Rabbit also wants to watch freda act cute (she obviously cannot program), so they decide that if the largest area you find is SS, each of them will give you SS taels of silver.

Input Format

The first line contains two integers NN and MM, meaning the rectangular land has NN rows and MM columns.

The next NN lines each contain MM characters separated by spaces, each being F or R, describing the land.

Output Format

Output a single integer, the amount of silver you can get, i.e., the value of 3×S3\times S.

5 6 
R F F F F F 
F F F F F F 
R R R F F F 
F F F F F F 
F F F F F F
45

Hint

Constraints:

  • For 50%50\% of the testdata, 1N,M2001 \leq N, M \leq 200.
  • For 100%100\% of the testdata, 1N,M10001 \leq N, M \leq 1000.

Translated by ChatGPT 5