Title: Give a map, find the largest sub-matrix in this map, so that the sub-matrix does not contain the letter ' R '.
Idea: The simple suspension line method to find the maximum sub-matrix, or not with the weight, very good. Long time no write hanging line, review.
CODE:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define MAX 1010using namespace Std; int M,n;bool map[max][max];int Max_left[max][max],max_right[max][max];int Max_up[max][max]; inline char GetChar () {char C; while (c = GetChar (), c = = ' | | c = = ' \ n ' | | c = = ' \ t ' | | c = = ' \ r '); return c;} int main () {cin >> m >> N; for (int i = 1, i <= m; ++i) for (int j = 1; j <= N; ++j) map[i][j] = GetChar () = = ' F '; for (int i = 1, i <= m; ++i) {for (int j = 1; j <= N; ++j) max_left[i][j] =!map[i][j]? 0:max_left I [j-1] + 1; for (int j = n; j;--j) max_right[i][j] =!map[i][j]? 0:max_right[i][j + 1] + 1; } for (int i = 1, i <= m; ++i) for (int j = 1; j <= N; ++j) if (Map[i][j] && map[i-1][j] ) {Max_up[i][j] = Max_up[i-1][j] + 1; Max_left[i][j] = min (max_left[i][j],max_left[i-1][j]); Max_right[i][j] = min (max_right[i][j],max_right[i-1][j]); } int ans = 0; for (int i = 1; I <= m; ++i) for (int j = 1; j <= N; ++j) ans = max (ans, (max_left[i][j] + max_right[ I][J]-1) * (Max_up[i][j] + 1)); cout << ans * 3 << Endl; return 0;}
Bzoj 3039 Jade Toad Hall Suspension line method