1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| #include <cstdio> #include <algorithm> using namespace std; const int N = 1e3 + 10; int n, m, A[N][N], l[N][N], r[N][N], up[N][N]; int main () { scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { char c; do scanf("%c", &c); while (c != 'R' && c != 'F'); A[i][j] = c == 'F'; } for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) l[i][j] = A[i][j - 1] ? l[i][j - 1] : j; for (int i = 1; i <= n; i++) for (int j = m; j; j--) r[i][j] = A[i][j + 1] ? r[i][j + 1] : j; int res = 0; for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { if (!A[i][j]) continue; if (A[i - 1][j]) { up[i][j] = up[i - 1][j] + 1; l[i][j] = max(l[i][j], l[i - 1][j]); r[i][j] = min(r[i][j], r[i - 1][j]); } else up[i][j] = 1; res = max(res, (r[i][j] - l[i][j] + 1) * up[i][j]); } printf("%d", res * 3); return 0; }
|