live archive 3029
发布日期:2021-08-28 19:37:23 浏览次数:4 分类:技术文章

本文共 2303 字,大约阅读时间需要 7 分钟。

hot3.png

/** * @brief live archive 3029 * @file 3029.cpp * @author mianma * @created 2015/01/05 14:18 * @edited  2015/01/05 14:18 * @type dp * @note */#include 
#include 
#include 
#include 
#include 
using namespace std;#define max(a, b)  ((a) > (b) ? (a) : (b))#define min(a, b)  ((a) > (b) ? (b) : (a)) #define abs(a)     ((a) >  0  ? (a) : (0 - (a)))#define CLR(vec)   memset(vec, 0, sizeof(vec))#ifdef DEBUGifstream in;ofstream out;#define CIN in#define COUT out#else#define CIN cin#define COUT cout#endif#define MAXN     (1000 + 10)int table[MAXN][MAXN];int up[MAXN][MAXN];int lft[MAXN][MAXN];int rht[MAXN][MAXN];int m, n, ans, cases;static inline void input(void){    char ch;    CLR(up);    CLR(rht);    CLR(lft);    CLR(table);    ans = 0;    CIN >> m >> n;    for(int i = 1; i <= m; i++)        for(int j = 1; j <= n; j++){            CIN >> ch;            if(ch == 'R') table[i][j] = 1;        }}static inline void output(void){        COUT << ans << "\n";}static inline void solve(void){    int record;    for(int i = 1; i <= m; i++){        record  = 0;        for(int j = 1; j <= n; j++){    /*check from lft to rht*/            if(!table[i][j]){                                        /*try to reset status for lft*/                lft[i][j] = lft[i - 1][j] == 0 ? 1 : lft[i - 1][j];                lft[i][j] = max( lft[i][j], record + 1);                up[i][j] = up[i - 1][j] + 1;            }else{                record = j;            }        }        record = n + 1;        for(int j = n; j >= 1; j--){    /*check from rht to lft*/            if(!table[i][j]){                                        /*try to reset status for rht*/                rht[i][j] = rht[i - 1][j] == 0 ? n : rht[i - 1][j];                rht[i][j] = min( rht[i][j], record - 1);                ans = max( ans, up[i][j] * (rht[i][j] - lft[i][j] + 1));            }else{                record = j;            }        }    }    ans *= 3;}int main(void){    ios_base::sync_with_stdio(0);#ifdef DEBUG    CIN.open("./in",   ios::in);    COUT.open("./out", ios::out);#endif    CIN >> cases;    while(cases--){        input();        solve();        output();    }    return 0;}

转载于:https://my.oschina.net/u/572632/blog/363919

转载地址:https://blog.csdn.net/weixin_33969116/article/details/92005872 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Openstack Ocata 设置镜像用户名秘密
下一篇:如何删除windows服务

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月11日 16时24分15秒