/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 9ms 540.0 KiB
#3 Wrong Answer 14ms 900.0 KiB
#4 Wrong Answer 14ms 956.0 KiB

Code

/*
 *Copyright (c) Swadheen Islam Robi (SIR01)
 *Created on Tue Dec 10 2024 3:07:03 PM
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pie 2*(acos(0.0))
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define endl "\n"
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define ALLAHU_AKBAR ios::sync_with_stdio(false); cin.tie(nullptr);

void sir()
{
    // int y
    ll n,m; cin>>n>>m;
    char grid[n+1][m+1];
    bool got = false;
    ll cp = 0;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=1; j<=m; j++)
        {
            cin>>grid[i][j];
            if(grid[i][j]=='+') got = true, cp++;
        }
    }
    if(!got){
        cout<<0<<endl;
        return;
    }
   
    vector<pair<ll,ll>>v;
    for(ll i=2; i<n; i++)
    {
        for(ll j=2; j<m; j++)
        {
            if(grid[i][j]=='+')
            {
                if(grid[i][j+1]=='+' && grid[i][j-1]=='+' && grid[i-1][j] =='+' && grid[i+1][j]=='+'){
                    v.pb({i,j});
                }
            }
        }
    }
    if(v.size()==0){
        cout<<1<<endl;
        return;
    }
    ll mx = -1, pmx = (min(n,m) * 2)-1;
    if(cp==(n*m))
    {
        cout<<pmx<<endl;
        return;
    }
    for(auto &p:v)
    {
        ll f = p.first, s = p.second;
        ll c = 0;
        ll x = 1;
        while(grid[f+x][s]=='+'&& grid[f-x][s]=='+'&& grid[f][s+x]=='+'&&grid[f][s-x]=='+' && (f+x<=n) && (f-x>=1)&& (s+x<=m)&& (s-x>=1)){
            c++; x++;
        }

        mx = max(mx, (4*c+1));
        //cout<<pmx<<" "<<c<<endl;
        if(mx == pmx){
            cout<<mx<<endl;
            return;
        }

    }
    cout<<mx<<endl;
}

int main() {
    ALLAHU_AKBAR

    ll t = 1;
    cin>>t;
    while(t--)
    {
        sir();
    }
    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 09:51:06
Judged At
2024-12-10 09:51:06
Judged By
Score
4
Total Time
14ms
Peak Memory
956.0 KiB