/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 14ms 788.0 KiB
#3 Accepted 9ms 556.0 KiB
#4 Accepted 10ms 932.0 KiB
#5 Accepted 12ms 836.0 KiB
#6 Accepted 10ms 796.0 KiB
#7 Accepted 27ms 796.0 KiB
#8 Accepted 47ms 840.0 KiB
#9 Accepted 49ms 2.254 MiB
#10 Accepted 59ms 2.355 MiB
#11 Accepted 34ms 2.215 MiB
#12 Accepted 38ms 16.82 MiB
#13 Accepted 39ms 17.004 MiB
#14 Accepted 36ms 16.785 MiB
#15 Accepted 37ms 16.77 MiB
#16 Accepted 35ms 16.77 MiB
#17 Accepted 35ms 16.98 MiB
#18 Accepted 38ms 16.773 MiB
#19 Accepted 46ms 16.77 MiB
#20 Accepted 38ms 16.77 MiB
#21 Accepted 225ms 65.695 MiB
#22 Accepted 225ms 65.914 MiB
#23 Accepted 309ms 65.91 MiB
#24 Accepted 275ms 65.914 MiB
#25 Accepted 302ms 65.922 MiB
#26 Accepted 222ms 65.914 MiB
#27 Accepted 316ms 65.906 MiB
#28 Accepted 324ms 65.91 MiB
#29 Accepted 236ms 66.078 MiB
#30 Accepted 310ms 65.91 MiB

Code

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

typedef long long ll;
#define bug(a) cout<<#a<<" : "<<a<<endl;
#define bug2(a,b) cout<<#a<<" : "<<a<<"\t"<<#b<<" : "<<b<<endl;


signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t=1;cin>>t;
    while(t--){
        int n,m;cin>>n>>m;
        vector<vector<char>>v(n,vector<char>(m));
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cin>>v[i][j];
            }
        }
         vector<vector<int>>lp(n,vector<int>(m)),rp(n,vector<int>(m)),up(n,vector<int>(m)),dp(n,vector<int>(m));
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(v[i][j]=='-')lp[i][j]=0;
                else{
                    if(j==0){
                        lp[i][j]=1;
                    }else{
                        lp[i][j]=1+lp[i][j-1];
                    }
                }
            }
        }
        for(int i=0;i<n;i++){
            for(int j=m-1;j>=0;j--){
                if(v[i][j]=='-')rp[i][j]=0;
                else{
                    if(j==m-1){
                        rp[i][j]=1;
                    }else{
                        rp[i][j]=1+rp[i][j+1];
                    }
                }
            }
        }
         for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(v[j][i]=='-')up[j][i]=0;
                else{
                    if(j==0){
                        up[j][i]=1;
                    }else{
                        up[j][i]=1+up[j-1][i];
                    }
                }
            }
        }
        for(int i=0;i<m;i++){
            for(int j=n-1;j>=0;j--){
                if(v[j][i]=='-')dp[j][i]=0;
                else{
                    if(j==n-1){
                        dp[j][i]=1;
                    }else{
                        dp[j][i]=1+dp[j+1][i];
                    }
                }
            }
        }
        // for(int i=0;i<m;i++){
        //     for(int j=n-1;j>=0;j--){
        //         cout<<dp[j][i]<<" ";
        //     }
        // }
        int ans=0;
        bool got=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(v[i][j]!='+')continue;
                if(i==0 || j==0 || i==n-1 || j==m-1){
                    ans=max(ans,1);
                    continue;
                }
                int ls=lp[i][j-1],rs=rp[i][j+1];
                //cout<<ls<<" "<<rs<<endl;
                int us=up[i-1][j],ds=dp[i+1][j];
                //cout<<us<<" "<<ds<<endl;
                int an=min({ls,rs,us,ds});
                ans = max(ans,4*an+1);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 07:13:09
Judged At
2024-12-09 07:13:09
Judged By
Score
100
Total Time
324ms
Peak Memory
66.078 MiB