/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 13ms 752.0 KiB
#3 Accepted 9ms 796.0 KiB
#4 Accepted 9ms 796.0 KiB
#5 Accepted 11ms 1008.0 KiB
#6 Accepted 9ms 748.0 KiB
#7 Accepted 28ms 1016.0 KiB
#8 Accepted 47ms 940.0 KiB
#9 Accepted 51ms 2.816 MiB
#10 Accepted 51ms 2.789 MiB
#11 Accepted 33ms 2.59 MiB
#12 Accepted 37ms 20.57 MiB
#13 Accepted 34ms 20.77 MiB
#14 Accepted 34ms 20.637 MiB
#15 Accepted 37ms 20.805 MiB
#16 Accepted 34ms 20.773 MiB
#17 Accepted 35ms 20.816 MiB
#18 Accepted 36ms 20.785 MiB
#19 Accepted 46ms 20.809 MiB
#20 Accepted 37ms 20.766 MiB
#21 Accepted 137ms 81.117 MiB
#22 Accepted 141ms 81.078 MiB
#23 Accepted 137ms 81.02 MiB
#24 Accepted 139ms 81.125 MiB
#25 Accepted 211ms 81.102 MiB
#26 Accepted 141ms 81.199 MiB
#27 Accepted 144ms 81.113 MiB
#28 Accepted 154ms 81.02 MiB
#29 Accepted 141ms 81.078 MiB
#30 Accepted 156ms 81.059 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define nl '\n'
#define f(i,s,n) for(int i = s; i < n; i++)
// #define int long long

void solve(){
   int n,m;
   cin>>n>>m;
   char s[n][m];
 for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
     char c;
     cin>>c;
     s[i][j]=c;
    }
   }
   vector<vector<int>>g(n,vector<int>(m)),a,b,c,d;
   for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        if(s[i][j]=='+'){
            g[i][j]=1;
        }
    }
   }
   a=b=c=d=g;
   for(int i=0;i<n;i++){
    for(int j=1;j<m;j++){
        if(s[i][j]!='+')continue;
        a[i][j]+=a[i][j-1];
    }
   }

   //
//     for(int i=0;i<n;i++){
//     for(int j=0;j<m;j++){
//        cout<<g[i][j]<<" ";
//     }
//     cout<<nl;
//    }
   
   //
      for(int i=1;i<n;i++){
    for(int j=0;j<m;j++){
         if(s[i][j]!='+')continue;
        b[i][j]+=b[i-1][j];
    }
   }
      for(int i=n-2;i>=0;i--){
    for(int j=0;j<m;j++){
         if(s[i][j]!='+')continue;
        c[i][j]+=c[i+1][j];
    }
   }
         for(int i=0;i<n;i++){
    for(int j=m-2;j>=0;j--){
         if(s[i][j]!='+')continue;
        d[i][j]+=d[i][j+1];
    }
   }
   int ans=0;
     for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
        int p=a[i][j];
        p=min(b[i][j],p);
        p=min(c[i][j],p);
        p=min(d[i][j],p);
        ans=max(ans,p*4-3);
    }
   }
   cout<<ans<<nl;


    
}

signed main() {
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   int T = 1;
    cin>>T;
   for(int tc = 1; tc <= T; tc++){
        solve();
   }
}

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 06:29:04
Judged At
2024-12-09 06:29:04
Judged By
Score
100
Total Time
211ms
Peak Memory
81.199 MiB