P4147-玉蟾宫

 1 #include <bits/stdc++.h>
 2 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 3 #define _rep(i,a,b) for(int i = (a);i > b;i --)
 4 #define INF 0x3f3f3f3f
 5 #define MOD 1000000007
 6 typedef long long ll;
 7 using namespace std;
 8 inline ll read()
 9 {
10     ll ans = 0;
11     char ch = getchar(), last = ' ';
12     while(!isdigit(ch)) last = ch, ch = getchar();
13     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
14     if(last == '-') ans = -ans;
15     return ans;
16 }
17 inline void write(ll x)
18 {
19     if(x < 0) x = -x, putchar('-');
20     if(x >= 10) write(x / 10);
21     putchar(x % 10 + '0');
22 }
23 
24 int N,M;
25 int a[1003][1003]; 
26 int lef[1003][1003];
27 int ri[1003][1003];
28 int up[1003][1003];
29 int main()
30 {
31     N = read(),M = read();
32     _for(i,1,N+1)
33         _for(j,1,M+1)
34         {
35             char c;
36             cin >> c;
37             if(c=='R')
38                 a[i][j] = 1;
39             else
40                 a[i][j] = 0;
41         }
42             
43     _for(j,1,M+1)
44     {
45         if(!a[1][j])
46             up[1][j] = 1;
47         _for(i,2,N+1)
48             if(!a[i][j])
49                 up[i][j] = up[i-1][j]+1;
50     }
51     
52     _for(i,1,N+1)
53     {
54         if(!a[i][1])
55             lef[i][1] = 1;
56         _for(j,2,M+1)
57             if(!a[i][j])
58                 lef[i][j] = lef[i][j-1]+1;
59     }
60     
61     _for(i,1,N+1)
62     {
63         if(!a[i][M])
64             ri[i][M] = 1;
65         _rep(j,M-1,0)
66             if(!a[i][j])
67                 ri[i][j] = ri[i][j+1]+1;
68     }
69     int ans = 0;
70     _for(i,1,N+1)
71          _for(j,1,M+1)
72          {
73              if(i>1 && !a[i][j] && !a[i-1][j])
74              {
75                 lef[i][j] = min(lef[i-1][j],lef[i][j]);
76                  ri[i][j] = min(ri[i-1][j],ri[i][j]);
77              }
78             ans = max(ans,up[i][j]*(ri[i][j]+lef[i][j]-1));
79         }
80     write(3*ans);
81     return 0;
82 }

 

posted @ 2019-08-28 16:42  Asurudo  阅读(152)  评论(0编辑  收藏  举报