/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 488.0 KiB
#2 Accepted 20ms 860.0 KiB
#3 Accepted 14ms 832.0 KiB
#4 Accepted 15ms 1.016 MiB
#5 Accepted 14ms 956.0 KiB
#6 Accepted 10ms 896.0 KiB
#7 Accepted 24ms 1.133 MiB
#8 Accepted 46ms 900.0 KiB
#9 Accepted 63ms 3.777 MiB
#10 Accepted 60ms 3.73 MiB
#11 Accepted 41ms 3.949 MiB
#12 Accepted 65ms 32.266 MiB
#13 Accepted 47ms 32.02 MiB
#14 Accepted 40ms 32.27 MiB
#15 Accepted 54ms 32.445 MiB
#16 Accepted 43ms 32.27 MiB
#17 Accepted 41ms 32.312 MiB
#18 Accepted 56ms 32.266 MiB
#19 Accepted 56ms 32.02 MiB
#20 Accepted 56ms 32.27 MiB
#21 Accepted 313ms 127.078 MiB
#22 Accepted 308ms 127.203 MiB
#23 Accepted 300ms 126.875 MiB
#24 Accepted 303ms 127.07 MiB
#25 Accepted 381ms 127.082 MiB
#26 Accepted 423ms 127.074 MiB
#27 Accepted 388ms 127.074 MiB
#28 Accepted 389ms 127.082 MiB
#29 Accepted 397ms 127.07 MiB
#30 Accepted 410ms 127.078 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

//o-set
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//debugging tool
template<typename T>
void debug(string name, T value) {
    cerr << name << " = " << value << endl;
}

template<typename T, typename U>
void debug(string name, pair<T, U> value) {
    cerr << name << " = {" << value.first << ", " << value.second << "}" << endl;
}

template<typename T>
void debug(string name, vector<T> v) {
    cerr << name << " =[ ";
    for (size_t i = 0; i < v.size(); i++) {
        if (i) {
            cerr << ", ";
        }
        cerr << v[i];
    }

    cerr << "]" << endl;
}

template<typename T>
void debug(string name, set<T> v) {
    cerr << name << " =[ ";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            cerr << ", ";
        }
        cerr << *it;
    }

    cerr << "]" << endl;
}



template<typename T, typename U>
void debug(string name, map<T, U> v) {
    cerr << name << " =[ ";
    for (auto it = v.begin(); it != v.end(); it++) {
        if (it != v.begin()) {
            cerr << ", ";
        }
        cerr << it->first << ": " << it->second;
    }

    cerr << "]" << endl;
}

#define DEBUG(x)        debug(#x, x);

#define int             long long
#define endl            "\n"
#define rep(i, a, b)    for (int i = 0; i < b; i++)
#define fr(i, a, b)    for (int i = 0; i <= b; i++)

typedef vector<int>     vi;















void solve() {
    int n,m;
    cin>>n>>m;
    vector<vector<char>>grid(n,vector<char>(m,0));
    vector<vector<int>>uptodown(n,vector<int>(m,0)),downtoup(n,vector<int>(m,0));
    vector<vector<int>>lefttoright(n,vector<int>(m,0)),righttoleft(n,vector<int>(m,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
             cin>>grid[i][j];
       }
    }

   for(int i=0;i<n;i++){
     int cnt=0;
    for(int j=0;j<m;j++){
         if(grid[i][j]=='+')cnt++,lefttoright[i][j]=cnt;
         else cnt=0;
    }
   }
   for(int i=0;i<n;i++){
     int cnt=0;
    for(int j=m-1;j>=0;j--){
         if(grid[i][j]=='+')cnt++,righttoleft[i][j]=cnt;
         else cnt=0;
    }
   }
   for(int i=0;i<m;i++){
      int cnt=0;
      for(int j=0;j<n;j++){
          if(grid[j][i]=='+')cnt++,uptodown[j][i]=cnt;
          else cnt=0;
      }
   }
    for(int i=0;i<m;i++){
      int cnt=0;
      for(int j=n-1;j>=0;j--){
          if(grid[j][i]=='+')cnt++,downtoup[j][i]=cnt;
          else cnt=0;
      }
   }
//    for(int i=0;i<n;i++){
//      for(int j=0;j<m;j++){
//           cout<<down[i][j]<<" ";
//      }
//      cout<<endl;
//    }
   int ans=0;
   for(int i=0;i<n;i++){
     for(int j=0;j<m;j++){
           if(grid[i][j]=='-')continue;
           int mn=INT_MAX;
           mn=min(mn,lefttoright[i][j]);
           mn=min(mn,righttoleft[i][j]);
           mn=min(mn,uptodown[i][j]);
           mn=min(mn,downtoup[i][j]);
          if(mn%2==0) ans=max(ans,4*(mn-1)+1);
          else{
               mn--;
               ans=max(ans,4*(mn)+1);
          }
     }
   }
   cout<<ans<<endl;


}
signed main() {
    ios_base::sync_with_stdio(false);cin.tie(0);

    int tt;     cin >> tt;
    
    while (tt--) 
        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 09:12:56
Judged At
2024-12-09 09:12:56
Judged By
Score
100
Total Time
423ms
Peak Memory
127.203 MiB