QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 33

#14010. 建房子

统计

你刚刚买下了一块土地,并希望种植一片尽可能大的矩形农田。在勘测土地时,你发现了一些障碍物,并决定绘制一张地图。你在地图的每个方格中标记了它包含的是草地(G)、岩石(R)、水(W)、灌木(S)还是树木(T)。虽然草地可以修剪,灌木可以从地里挖出,但水、岩石和树木是无法移除的。在存在这些障碍物的情况下,请确定最大矩形农田的面积。

输入格式

输入的第一行给出测试用例的数量 N

接下来是 N 个测试用例。对于每个测试用例:

  • 第一行包含两个空格分隔的整数,分别表示土地的长度(L)和宽度(W)。
  • 接下来的 W 行,每行包含 L 个字符,每个字符表示该方格土地的状况(GRWST 之一)。

输出格式

对于每个测试用例,输出一行,格式为 "Case #x: ",后接可以清理出的最大矩形的最大面积。

数据范围

  • 1 ≤ L ≤ 50
  • 1 ≤ W ≤ 50

小数据规模(10 分)

  • N ≤ 10
  • 每个测试用例中障碍物少于 5 个。

大数据规模(23 分)

  • N ≤ 30
  • 每个测试用例中障碍物少于 20 个。

样例

输入样例 1

4
1 1
G
2 2
GS
SG
2 2
GT
GG
5 8
GGTGG
TGGGG
GSSGT
GGGGT
GWGGG
RGTRT
RTGWT
WTWGR

输出样例 1

Case #1: 1
Case #2: 4
Case #3: 2
Case #4: 9

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.