/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 15ms 864.0 KiB
#3 Accepted 9ms 876.0 KiB
#4 Accepted 9ms 1.004 MiB
#5 Accepted 11ms 1.086 MiB
#6 Accepted 9ms 908.0 KiB
#7 Accepted 25ms 900.0 KiB
#8 Accepted 48ms 1.055 MiB
#9 Accepted 62ms 3.785 MiB
#10 Accepted 61ms 3.742 MiB
#11 Accepted 40ms 3.805 MiB
#12 Accepted 61ms 32.066 MiB
#13 Accepted 45ms 32.082 MiB
#14 Accepted 37ms 32.305 MiB
#15 Accepted 53ms 32.27 MiB
#16 Accepted 41ms 32.246 MiB
#17 Accepted 38ms 32.098 MiB
#18 Accepted 62ms 32.098 MiB
#19 Accepted 54ms 32.461 MiB
#20 Accepted 62ms 32.266 MiB
#21 Accepted 274ms 127.082 MiB
#22 Accepted 262ms 127.109 MiB
#23 Accepted 261ms 127.125 MiB
#24 Accepted 258ms 127.223 MiB
#25 Accepted 283ms 127.234 MiB
#26 Accepted 294ms 127.078 MiB
#27 Accepted 294ms 127.078 MiB
#28 Accepted 284ms 126.863 MiB
#29 Accepted 325ms 127.227 MiB
#30 Accepted 327ms 127.09 MiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define all(v) v.begin(),v.end()
#define nl "\n"
#define FIO \
    ios_base::sync_with_stdio(false);\
    cin.tie(NULL);\
    cout.tie(NULL);
const int N=1e5+9;
vector<vector<ll>>g; bool vis[N];
vector<ll>par, dis, col, topo, indegree;
void clr(ll n){
    g.clear(); par.clear(); dis.clear();
    g.resize(n+1); col.assign(n+1, 0);
    indegree.assign(n+1, 0);
    par.assign(n+1, -1); dis.assign(n+1, 0);
    fill(vis, vis+n+1, false);
}
void solve(){
    ll n, m; cin>>n>>m;
    vector<vector<char>>g(n, vector<char>(m));
    vector<vector<ll>>plusl(n, vector<ll>(m, 0));
    vector<vector<ll>>plusr(n, vector<ll>(m, 0));
    vector<vector<ll>>plusu(n, vector<ll>(m, 0));
    vector<vector<ll>>plusd(n, vector<ll>(m, 0));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            cin>>g[i][j];
        }
    }
    for(ll i=0;i<n;i++)
    {
        ll k=0; if(g[i][0]=='+') plusl[i][0]++, k=1;
        for(ll j=1;j<m;j++)
        {
            if(g[i][j]=='+'){
                if(g[i][j]==g[i][j-1]) k++;
                else k=1;
                plusl[i][j]=k;
            }else k=0;
        }
        k=0; if(g[i][m-1]=='+') plusr[i][m-1]++, k=1;
        for(ll j=m-2; j>=0; j--){
            if(g[i][j]=='+'){
                if(g[i][j]==g[i][j+1]) k++;
                else k=1;
                plusr[i][j]=k;
            }else k=0;
        }
    }

    for(ll j=0;j<m;j++)
    {
        ll k=0; if(g[0][j]=='+') plusu[0][j]++, k=1;
        for(ll i=1;i<n;i++)
        {
            if(g[i][j]=='+'){
                if(g[i][j]==g[i-1][j]) k++;
                else k=1;
                plusu[i][j]=k;
            }else k=0;
        }
        k=0; if(g[n-1][j]=='+') plusd[n-1][j]++, k=1;
        for(ll i=n-2; i>=0; i--){
            if(g[i][j]=='+'){
                if(g[i][j]==g[i+1][j]) k++;
                else k=1;
                plusd[i][j]=k;
            }else k=0;
        }
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            if(g[i][j]=='+'){
                ll k=min({plusu[i][j], plusd[i][j], plusl[i][j], plusr[i][j]});
                k*=4; k-=3; ans=max(ans, k);
            }
        }
    }
    cout<<ans<<nl;
}

int32_t main()
{
 FIO
    ll t=1;
    cin>>t;
    for(ll i=1;i<=t;i++)
    {
        // cout<<"Case "<<i<<": ";
        solve();
    }
}

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:00:53
Judged At
2024-12-10 10:00:53
Judged By
Score
100
Total Time
327ms
Peak Memory
127.234 MiB