/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 332.0 KiB
#2 Accepted 11ms 588.0 KiB
#3 Accepted 6ms 796.0 KiB
#4 Accepted 7ms 868.0 KiB
#5 Accepted 9ms 844.0 KiB
#6 Accepted 7ms 864.0 KiB
#7 Accepted 20ms 880.0 KiB
#8 Accepted 40ms 1.027 MiB
#9 Accepted 43ms 3.605 MiB
#10 Accepted 43ms 3.684 MiB
#11 Accepted 23ms 3.57 MiB
#12 Accepted 58ms 32.012 MiB
#13 Accepted 56ms 32.02 MiB
#14 Accepted 53ms 31.848 MiB
#15 Accepted 62ms 32.02 MiB
#16 Accepted 55ms 32.227 MiB
#17 Accepted 55ms 32.004 MiB
#18 Accepted 57ms 31.855 MiB
#19 Accepted 64ms 32.062 MiB
#20 Accepted 57ms 32.289 MiB
#21 Accepted 296ms 126.773 MiB
#22 Accepted 304ms 126.668 MiB
#23 Accepted 300ms 126.609 MiB
#24 Accepted 303ms 126.672 MiB
#25 Accepted 365ms 126.672 MiB
#26 Accepted 300ms 126.676 MiB
#27 Accepted 292ms 126.668 MiB
#28 Accepted 328ms 126.504 MiB
#29 Accepted 299ms 126.672 MiB
#30 Accepted 307ms 126.469 MiB

Code

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tc=1,tc1=1;
    cin>>tc;
    up:
    while(tc--){
      ll n,m;
      cin>>n>>m;
      char s[n][m];
      for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
          cin>>s[i][j];
        }
      }
      ll l[n][m],r[n][m],u[n][m],d[n][m],g=0;
      for(ll i=0;i<n;i++){
        ll c=0;
        for(ll j=0;j<m;j++){
          if(s[i][j]=='+'){
            c++;
            g=1;
          }
          else {
            c=0;
          }
          l[i][j]=c;
        }
      }
      for(ll i=0;i<n;i++){
        ll c=0;
        for(ll j=m-1;j>=0;j--){
          if(s[i][j]=='+'){
            c++;
          }
          else {
            c=0;
          }
          r[i][j]=c;
        }
      }
      for(ll i=0;i<m;i++){
        ll c=0;
        for(ll j=0;j<n;j++){
          if(s[j][i]=='+'){
            c++;
          }
          else {
            c=0;
          }
          u[j][i]=c;
        }
      }
      for(ll i=0;i<m;i++){
        ll c=0;
        for(ll j=n-1;j>=0;j--){
          if(s[j][i]=='+'){
            c++;
          }
          else {
            c=0;
          }
          d[j][i]=c;
        }
      }
      ll mx=g;
      for(ll i=1;i<n-1;i++){
        for(ll j=1;j<m-1;j++){
          if(s[i][j]=='-'){
            continue;
          }
          ll mn=min({l[i][j-1],r[i][j+1],d[i+1][j],u[i-1][j]});
          mx=max(mx,mn*4+1);
        }
      }
      cout<<mx<<'\n';
    }
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU IUJPC : Sylhet Division 2024 Replay Contest
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-10 10:32:37
Judged At
2024-12-10 10:32:37
Judged By
Score
100
Total Time
365ms
Peak Memory
126.773 MiB