/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 768.0 KiB
#2 Accepted 14ms 796.0 KiB
#3 Accepted 9ms 868.0 KiB
#4 Accepted 9ms 1.027 MiB
#5 Accepted 11ms 920.0 KiB
#6 Accepted 9ms 1.07 MiB
#7 Accepted 25ms 900.0 KiB
#8 Accepted 46ms 892.0 KiB
#9 Accepted 61ms 3.789 MiB
#10 Accepted 60ms 3.715 MiB
#11 Accepted 41ms 3.734 MiB
#12 Accepted 60ms 32.184 MiB
#13 Accepted 45ms 32.277 MiB
#14 Accepted 39ms 32.281 MiB
#15 Accepted 52ms 32.312 MiB
#16 Accepted 39ms 32.504 MiB
#17 Accepted 39ms 32.27 MiB
#18 Accepted 60ms 32.152 MiB
#19 Accepted 56ms 32.266 MiB
#20 Accepted 58ms 32.055 MiB
#21 Accepted 267ms 127.074 MiB
#22 Accepted 254ms 127.02 MiB
#23 Accepted 255ms 127.094 MiB
#24 Accepted 257ms 127.277 MiB
#25 Accepted 276ms 126.852 MiB
#26 Accepted 261ms 127.082 MiB
#27 Accepted 279ms 127.258 MiB
#28 Accepted 267ms 126.969 MiB
#29 Accepted 265ms 127.078 MiB
#30 Accepted 261ms 127.078 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
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 05:49:07
Judged At
2024-12-09 05:49:07
Judged By
Score
100
Total Time
279ms
Peak Memory
127.277 MiB