/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 2.527 MiB
#2 Accepted 11ms 6.926 MiB
#3 Accepted 8ms 6.777 MiB
#4 Accepted 13ms 6.562 MiB
#5 Accepted 14ms 4.824 MiB
#6 Accepted 8ms 4.777 MiB
#7 Accepted 24ms 6.574 MiB
#8 Accepted 37ms 4.895 MiB
#9 Accepted 43ms 18.793 MiB
#10 Accepted 38ms 9.52 MiB
#11 Accepted 25ms 10.527 MiB
#12 Accepted 36ms 35.777 MiB
#13 Accepted 33ms 36.77 MiB
#14 Accepted 28ms 36.867 MiB
#15 Accepted 33ms 35.023 MiB
#16 Accepted 44ms 36.52 MiB
#17 Accepted 29ms 35.52 MiB
#18 Accepted 36ms 35.277 MiB
#19 Accepted 40ms 35.566 MiB
#20 Accepted 34ms 33.27 MiB
#21 Accepted 124ms 65.645 MiB
#22 Accepted 122ms 65.52 MiB
#23 Accepted 123ms 65.801 MiB
#24 Accepted 120ms 65.52 MiB
#25 Accepted 155ms 65.645 MiB
#26 Accepted 126ms 65.77 MiB
#27 Accepted 122ms 65.77 MiB
#28 Accepted 123ms 65.656 MiB
#29 Accepted 122ms 65.574 MiB
#30 Accepted 127ms 65.648 MiB

Code

/**
*  Problem Name: Plus_of_Pluses
*  Author: MJS
*  Created: 16 December 2024, Monday (14:12:01)...
**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define nl '\n' 

struct g{
    int l,r,u,d;
};

int n,m;
char c[2002][2002];
g dp[2002][2002];

void answer_to_the_question(){
    cin>>n>>m;
    for(int i=0;i<=n+1;i++){
        for(int j=0;j<=m+1;j++){
            dp[i][j].l=dp[i][j].r=dp[i][j].u=dp[i][j].d=-1;
            c[i][j]='-';
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>c[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(c[i][j]=='+'){
                dp[i][j].l=dp[i][j-1].l+1;
            }
        }
        for(int j=m;j>0;j--){
            if(c[i][j]=='+'){
                dp[i][j].r=dp[i][j+1].r+1;
            }
        }
    }
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(c[j][i]=='+'){
                dp[j][i].u=dp[j-1][i].u+1;
            }
        }
        for(int j=n;j>0;j--){
            if(c[j][i]=='+'){
                dp[j][i].d=dp[j+1][i].d+1;
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int mn=min({dp[i][j].l,dp[i][j].r,dp[i][j].u,dp[i][j].d});
            ans=max(ans,4*mn+1);
        }
    }
    cout<<ans<<nl;
}

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int test_case;    cin>>test_case;

    for(int MJS=1; MJS<=test_case; MJS++){
        answer_to_the_question();
    }

    return 0;
}

// Hi..

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-18 03:45:49
Judged At
2024-12-18 03:45:49
Judged By
Score
100
Total Time
155ms
Peak Memory
65.801 MiB