/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 8.527 MiB
#2 Accepted 14ms 10.781 MiB
#3 Accepted 10ms 11.004 MiB
#4 Accepted 11ms 12.77 MiB
#5 Accepted 12ms 10.945 MiB
#6 Accepted 10ms 12.559 MiB
#7 Accepted 28ms 12.773 MiB
#8 Accepted 44ms 10.777 MiB
#9 Accepted 50ms 27.488 MiB
#10 Accepted 45ms 15.27 MiB
#11 Accepted 27ms 16.52 MiB
#12 Accepted 37ms 43.773 MiB
#13 Accepted 36ms 43.27 MiB
#14 Accepted 37ms 42.52 MiB
#15 Accepted 39ms 44.016 MiB
#16 Accepted 38ms 44.02 MiB
#17 Accepted 38ms 41.77 MiB
#18 Accepted 36ms 42.742 MiB
#19 Accepted 42ms 41.02 MiB
#20 Accepted 36ms 40.559 MiB
#21 Accepted 120ms 65.77 MiB
#22 Accepted 120ms 65.84 MiB
#23 Accepted 117ms 65.68 MiB
#24 Accepted 114ms 65.812 MiB
#25 Accepted 179ms 65.836 MiB
#26 Accepted 131ms 65.832 MiB
#27 Accepted 134ms 65.816 MiB
#28 Accepted 139ms 65.824 MiB
#29 Accepted 136ms 65.836 MiB
#30 Accepted 122ms 65.797 MiB

Code

#include <bits/stdc++.h>
using namespace std;
 
#define inf 1013161010
#define mod 1000000007
#define mod1 998244353
#define ll long long
#define lf long double
#define sz(x) ((int)x.size())
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,a,b) for(ll i=a;i<=b;i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)
 
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
 
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;
 
ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}
 
template <typename T>
void print1(T arr[], int n) { rep(i, n) { cout << arr[i] << " "; } cout << endl; }
 
template <typename T, size_t N, size_t M>
void print2(T (&arr)[N][M], int n, int m) { rep(i, n) { rep(j, m) { cout << arr[i][j] << " "; } cout << endl; } cout << endl; }
 
template <typename T>
void print1v(const vector<T>& vec, int n) { for (int i = 0; i < n && i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
 
template <typename T>
void print2v(const vector<vector<T>>& vec, int n, int m) { for (int i = 0; i < n && i < vec.size(); i++) { for (int j = 0; j < m && j < vec[i].size(); j++) { cout << vec[i][j] << " "; } cout << endl; } cout << endl;}
 
const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;
 
ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
ll fast_pow(ll a,ll m, ll mode) { if(m==0) return 1; else if(m==1) return a; ll h=fast_pow(a,m/2,mode); if(m%2==0) return ((h*h)%mode); else return ((((h*h)%mode)*a)%mode);}
ll mmi(ll b, ll mode){return fast_pow(b, mode-2, mode);}
 
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};
  
char arr[2005][2005];
int v1[2005][2005], v2[2005][2005], v3[2005][2005], v4[2005][2005];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1;
    cin >> t;

    while (t--) {
      
      ll n, m, k, x, ans=0;
      cin >> n >> m;
      rep(i, n) {
        rep(j, m) {
          cin >> arr[i][j];
          v1[i][j] = 0;
          v2[i][j] = 0;
          v3[i][j] = 0;
          v4[i][j] = 0;
        }
      }
      
      for (int i = 0; i < n; i++ ) {
        if (arr[i][0] == '+') {
          v1[i][0] = 1;
        }
        for (int j = 1; j < m; j++) {
          if (arr[i][j] == '+') {
            v1[i][j] = v1[i][j-1] + 1;
          } else {
            v1[i][j] = 0;
          }
        }
      }
      
      for (int i = 0; i < n; i++ ) {
        if (arr[i][m-1] == '+') {
          v2[i][m-1] = 1;
        }
        for (int j = m-2; j >= 0; j--) {
          if (arr[i][j] == '+') {
            v2[i][j] = v2[i][j+1] + 1;
          } else {
            v2[i][j] = 0;
          }
        }
      }
      
      for (int j = 0; j < m; j++ ) {
        if (arr[0][j] == '+') {
          v3[0][j] = 1;
        }
        for (int i = 1; i < n; i++) {
          if (arr[i][j] == '+') {
            v3[i][j] = v3[i-1][j] + 1;
          } else {
            v3[i][j] = 0;
          }
        }
      }
      
      for (int j = 0; j < m; j++ ) {
        if (arr[n-1][j] == '+') {
          v4[n-1][j] = 1;
        }
        for (int i = n-2; i >= 0; i--) {
          if (arr[i][j] == '+') {
            v4[i][j] = v4[i+1][j] + 1;
          } else {
            v4[i][j] = 0;
          }
        }
      }

      ans = 0;
      rep(i, n) {
        rep(j, m) {
          if (arr[i][j] == '+') {
            ll side = min(v1[i][j], min(v2[i][j], min(v3[i][j], v4[i][j]))) - 1;
            ans = max(side*4+1, ans);
          }
        }
      }

      cout << ans << endl;
    }
    return 0;
}

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:04:42
Judged At
2024-12-10 10:04:42
Judged By
Score
100
Total Time
179ms
Peak Memory
65.84 MiB