QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 128 MB Puntuación total: 100

#10767. Gifts

Estadísticas

Xiao Bai's birthday is coming up, and Xiao Lan has decided to give a handmade craft to make the gift unique. Specifically, Xiao Lan has already created a $p \times q \times r$ wooden block (composed of $pqr$ unit wooden blocks). However, due to Xiao Lan's lack of craftsmanship, some of the unit blocks in this wooden block are defective (having cracks, being hollow inside, etc.). Xiao Lan cannot give such a gift directly.

Therefore, Xiao Lan decided to carve out an $a \times a \times b$ sub-block from this wooden block (meaning the rectangular block carved out must have two adjacent sides of equal length). Naturally, this sub-block must not contain any defective unit blocks. To ensure the block can contain more patterns, Xiao Lan hopes to choose the solution that maximizes the value of $4ab$ from all feasible options. However, Xiao Lan has exhausted all energy just by detecting which parts of the block are defective. As Xiao Lan's friend, can you help?

Input

Each input file contains only one test case.

The first line contains three space-separated positive integers, $p, q, r$.

Following this are $pq$ lines, each containing $r$ characters. Each character is either 'P' (Poor) or 'N' (Nice), indicating whether the unit block is defective or not. Specifically, the $z$-th character of the $1+(y-1)p+(x-1)+1$ line (or more simply, the $z$-th character of the line corresponding to coordinates $(x, y)$) describes the state of the unit block at coordinates $(x, y, z)$. ($1 \le x \le p, 1 \le y \le q, 1 \le z \le r$)

Output

The output file contains only one integer, representing the maximum value of $4ab$ for the best solution.

Examples

Input 1

3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP

Output 1

24

Constraints

For 100% of the data, $0 < p, q, r \le 150$, and the input contains at least one 'N'.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.