/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 25ms 692.0 KiB
#3 Accepted 21ms 788.0 KiB
#4 Accepted 22ms 540.0 KiB
#5 Accepted 26ms 864.0 KiB
#6 Accepted 22ms 840.0 KiB
#7 Accepted 84ms 540.0 KiB
#8 Accepted 94ms 584.0 KiB
#9 Accepted 95ms 2.102 MiB
#10 Accepted 91ms 2.02 MiB
#11 Accepted 73ms 2.234 MiB
#12 Accepted 96ms 16.77 MiB
#13 Accepted 89ms 16.855 MiB
#14 Accepted 81ms 16.734 MiB
#15 Accepted 91ms 16.723 MiB
#16 Accepted 83ms 16.797 MiB
#17 Accepted 80ms 16.863 MiB
#18 Accepted 95ms 16.984 MiB
#19 Accepted 92ms 17.082 MiB
#20 Accepted 96ms 16.848 MiB
#21 Accepted 416ms 65.727 MiB
#22 Accepted 465ms 65.523 MiB
#23 Accepted 452ms 65.73 MiB
#24 Accepted 562ms 65.73 MiB
#25 Accepted 455ms 65.602 MiB
#26 Accepted 427ms 65.727 MiB
#27 Accepted 438ms 65.73 MiB
#28 Accepted 436ms 65.691 MiB
#29 Accepted 437ms 65.801 MiB
#30 Accepted 435ms 65.605 MiB

Code

#include <bits/stdc++.h>
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set1;
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set2;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_s;
typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_s2;
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
const int N = 1200300;
#define pi 2 * acos(0.0)
#define vll vector<ll>
#define pq_ priority_queue
#define pq_min <int,vector<int>,greater<int>>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pb push_back
#define sp ' '
#define sz(n) (int)n.size()
#define all(n) n.begin(), n.end()
#define rall(n) n.rbegin(), n.rend()
#define YES cout << "YES\n";
#define yes cout << "yes\n";
#define NO cout << "NO\n";
#define no cout << "no\n";
#define bye return 0;
#define ss second;
#define ff first;
const double eps = 1e-9;
const int MAX = 1e5;
const int lim = 1e6;
bool odd(ll num) { return ((num & 1) == 1); }
bool even(ll num) { return ((num & 1) == 0); }
bool isEqual(double a, double b) { return abs(a - b) < eps; }
bool isGreater(double a, double b) { return a >= b + eps; }
bool isGreaterEqual(double a, double b) { return a > b - eps; }
#define tc     \
    int tt;    \
    cin >> tt; \
    while (tt--)
#define mset(n, v) memset(n, v, sizeof(n))
#define chk(n) for (auto it : n)
#define ff1(i, n) for (int i = 1; i <= n; i++)
#define lcm(a, b) (((a) * (b)) / __gcd(a, b))
int dx[8] = {1, -1, 0, 0, 1, -1, -1, 1};
int dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll mn(ll x, ll y)
{
    if (x < y)
        return x;
    else
        return y;
}
ll maxx(ll x, ll y)
{
    if (x > y)
        return x;
    else
        return y;
}
string bin(int n)
{
    std::string binary;

    while (n > 0)
    {
        ll x=n%2;
        char y = x+'0';
        binary+=y;
        n /= 2;
    }

    // Reverse the vector to get the binary representation in correct order
    std::reverse(binary.begin(), binary.end());

    return binary;
}


ll POW(ll a, ll b)
{
    if (!b)
        return 1;
    ll r = POW(a, b / 2);
    if (b % 2)
        return r * r * a;
    else
        return r * r;
}
void pri(vi v)
{
    for (auto it : v)
        cout << it << ' ';
    cout << endl;
}
void pri1(vi v)
{
    for (auto it : v)
        cout << it << ' ';
  
}
void pro(vll v)
{
    for (auto it : v)
        cout << it << ' ';
    cout << endl;
}
int mex(vi v, int l, int r)
{
    vi a;
    for (int i = l; i <= r; i++)
    {
        a.pb(v[i]);
    }
    sort(all(a));
    for (int i = 0, j = 1; i < a.size(); i++)
    {
        if (a[i] == j)
        {
            j++;
        }
        else
        {
            return j;
        }
    }
    return a.back() + 1;
}
vector<int> cps(const vector<int> &arr)
{
    int n = arr.size();
    vector<int> prefixSum(n);

    if (n > 0)
    {
        prefixSum[0] = arr[0];
        for (int i = 1; i < n; ++i)
        {
            prefixSum[i] = prefixSum[i - 1] + arr[i];
        }
    }

    return prefixSum;
}

bool comp(pair<int, int> x, pair<int, int> y)
{
    if (x.second > y.second)
        return true;
    else if (x.second == y.second)
    {
        if (x.first > y.first)
            return true;
        else
            return false;
    }
    else
        return false;
}
bool comp1(pair<int, pair<int, int>> x, pair<int, pair<int, int>> y)
{
    if (x.first > y.first)
        return true;
    else if (x.first == y.first)
    {
        if (x.second.second < y.second.second)
            return true;
        else
            return false;
    }
    else
        return false;
}
bool comp2(pair<int, pair<int, int>> x, pair<int, pair<int, int>> y)
{
    if (x.second.first > y.second.first)
        return true;
    else if (x.second.first == y.second.first)
    {
        if (x.second.second < y.second.second)
            return true;
        else
            return false;
    }
    else
        return false;
}
ll PoW(ll base, ll exponent)
{
    ll result = 1;
    for (int i = 0; i < exponent; ++i)
    {
        result = (result * base) % 10;
        ;
    }
    return result;
}

bool isp(ll num)
{
    ll om = num;
    ll rm = 0;
    while (num > 0)
    {
        ll digit = num % 10;
        rm = rm * 10 + digit;
        num /= 10;
    }
    return om == rm;
}
string lcs(const std::vector<std::string> &strs)
{
    std::vector<std::string::const_reverse_iterator> backs;
    std::string s;
    if (strs.size() == 0)
        return "";
    if (strs.size() == 1)
        return strs[0];
    for (auto &str : strs)
        backs.push_back(str.crbegin());
    while (backs[0] != strs[0].crend())
    {
        char ch = *backs[0]++;
        for (std::size_t i = 1; i < strs.size(); i++)
        {
            if (backs[i] == strs[i].crend())
                goto done;
            if (*backs[i] != ch)
                goto done;
            backs[i]++;
        }
        s.push_back(ch);
    }
done:
    reverse(s.begin(), s.end());
    return s;
}
bool leap(int year)
{
    return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
}
bool isd(string s, ll d, ll y)
{
    if (d == 32)
        return 0;
    if (s == "April" || s == "June" || s == "September" || s == "November")
    {
        if (d == 31)
            return 0;
        return 1;
    }
    if (d > 28 && s == "February")
    {
        if (d == 29 && leap(y))
        {
            return 1;
        }
        return 0;
    }
    return 1;
}
vll pref(vll v)
{
    vll pr;
    pr.pb(v.front());
    for (int i = 1; i < v.size(); i++)
    {
        pr.pb(v[i] + pr[i - 1]);
    }
    return pr;
}
ll cxor(vi v, ll l, ll r)
{
    ll xo = v[l];
    for (int i = l + 1; i <= r; i++)
    {
        xo ^= v[i];
    }
    return xo;
}
#define seea(a, x, y)           \
    for (int i = x; i < y; i++) \
    {                           \
        cin >> a[i];            \
    }
#define seev(v, n)              \
    for (int i = 0; i < n; i++) \
    {                           \
        int x;                  \
        cin >> x;               \
        v.push_back(x);         \
    }
#define sees(s, n)              \
    for (int i = 0; i < n; i++) \
    {                           \
        int x;                  \
        cin >> x;               \
        s.insert(x);            \
    }
bool is(int num, int pos)
{
    // Create a mask with only the i'th bit set
    int mask = 1 << pos;

    // Perform bitwise AND operation to isolate the i'th bit
    int result = num & mask;

    // Check if the result is non-zero (bit is set)
    return result != 0;
}

// By Nitin Patel
// Function to merge two sorted subarrays of a given array
void merge(long long start, long long end,
           vector<long long> &prefix)
{
    long long n = end - start + 1;
    long long mid = (start + end) / 2;
    vector<long long> temp(n, 0);
    long long i = start;
    long long j = mid + 1;
    long long k = 0;

    // Merge the two subarrays in sorted order
    while (i <= mid and j <= end)
    {
        if (prefix[i] <= prefix[j])
        {
            temp[k++] = prefix[i++];
        }
        else
        {
            temp[k++] = prefix[j++];
        }
    }

    // Copy the remaining elements of the left subarray, if
    // any
    while (i <= mid)
    {
        temp[k++] = prefix[i++];
    }

    // Copy the remaining elements of the right subarray, if
    // any
    while (j <= end)
    {
        temp[k++] = prefix[j++];
    }

    // Copy the merged subarray back to the original array
    for (int t = start; t <= end; t++)
    {
        prefix[t] = temp[t - start];
    }
}

bool isvo(char x)
{
    if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u')
        return 1;
    return 0;
}
bool is_prime(ll x)
{
    for (ll i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
        {
            return 0;
        }
    }
    return 1;
}
bool cm(pair<char, pair<int, int>> x, pair<char, pair<int, int>> y)
{
    if (x.second.first == y.second.first)
    {
        if (x.second.second > y.second.second)
        {
            return 1;
        }
        return 0;
    }
    else
    {
        return x.second.first < y.second.first;
    }
}

vll sieve(ll n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false; // 0 and 1 are not prime numbers.

    for (ll i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            for (ll j = i * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    ll cn=0;
    vll primes;
    for (ll i = 2; i <= n; i++) {
        if (is_prime[i]) {
            if(i<=n*n)
                primes.pb(i);
          
        }
    }
    return primes;
}
bool cc(pair<vi,int> xx,pair<vi,int> yy){
   ll cn=0;;
    vi x=xx.first, y=yy.first;
    for(int i=0;i<5;i++){
        if(x[i] <y[i]){
            cn++;
        }
    }
    return cn>5-cn;

}
int main()
{
  tc{
        ll n, m;
        cin>>n>>m;
        vector<vector<char>>s(n);
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                char c;
                cin>>c;
                s[i].pb(c);
            }
        }
        int prc[n+1][m+1], sfc[n+1][m+1];
        int prr[n+1][m+1], sfr[n+1][m+1];
        memset(prc, 0, sizeof(prc));
        memset(sfc, 0, sizeof(sfc));
        memset(prr, 0, sizeof(prr));
        memset(sfr, 0, sizeof(sfr));
      
        for(int i=0;i<n;i++){
            ll cn=0;
            for(int j=0;j<m;j++){
                if(s[i][j]=='+'){
                    cn++;
                    prc[i][j]=cn;
                    
                }
                else{
                    cn=0;
                }
            }
             cn=0;
            for(int j=m-1;j>=0;j--){
                if(s[i][j]=='+'){
                    cn++;
                    sfc[i][j]=cn;
                }
                else{
                    cn=0;
                }
            }
        }
        for(int i=0;i<m;i++){
            ll cn=0;
            for(int j=0;j<n;j++){
                if(s[j][i]=='+'){
                    cn++;
                    prr[j][i]=cn;
                }
                else{
                    cn=0;
                }
            }
            cn=0;
            for(int j=n-1;j>=0;j--){
                if(s[j][i]=='+'){
                    cn++;
                    sfr[j][i]=cn;
                }
                else{
                    cn=0;
                }
            }
        }
        ll ans=0;
        for(int i=0;i<n;i++){

            for(int j=0;j<m;j++){
                ans=max(ans, 1ll*min(prc[i][j], min(prr[i][j], min(sfc[i][j], sfr[i][j]))));    
            }
           
        }
        cout<<max(0ll,(ans-1)*4+1)<<endl;

  }
}

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:43:45
Judged At
2024-12-10 10:43:45
Judged By
Score
100
Total Time
562ms
Peak Memory
65.801 MiB