网上应该没有一样的代码吧、参考1506的做法
#include <iostream>
using namespace std;
int Lu[1002][1002], Hui[1002][1002], Yi[1002][1002];
int main()
{
int n;
int x, y;
cin >> n;
while (n--)
{
cin >> x >> y;
int Max = 0;
memset(Lu, 0, sizeof(Lu));
memset(Hui, 0, sizeof(Hui));
memset(Yi, 0, sizeof(Yi));
for (int i = 1; i <= x; i++)
for (int j = 1; j <= y; j++)
{
char c;
cin >> c;
if (c == 'F')
{
Lu[i][j] = 1;
Hui[i][j] = Yi[i][j] = 1;
}
if (Lu[i - 1][j] >= 1 && Lu[i][j] >= 1 && i >= 2)
Lu[i][j] += Lu[i - 1][j];
}
for (int i = 1; i <= x; i++)
for (int j = 2; j <= y; j++)
{
int q = j - 1;
if (Lu[i][j] <= Lu[i][q] && q >= 1)
Hui[i][j] += Hui[i][q];
q = q - Hui[i][q];
}
for (int i = 1; i <= x; i++)
for (int j = y - 1; j >= 1; j--)
{
int q = j + 1;
if (Lu[i][j] <= Lu[i][q] && q <= y)
Yi[i][j] += Yi[i][q];
q = q + Yi[i][q];
}
for (int i = 1; i <= x; i++)
for (int j = 1; j <= y; j++)
{
int temp = (Hui[i][j] + Yi[i][j] - 1) * Lu[i][j];
if (Max < temp)
Max = temp;
}
cout << Max * 3 << endl;
}
return 0;
}