/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 13ms 540.0 KiB
#3 Accepted 31ms 556.0 KiB
#4 Accepted 36ms 540.0 KiB
#5 Accepted 26ms 540.0 KiB
#6 Accepted 36ms 540.0 KiB
#7 Accepted 171ms 772.0 KiB
#8 Accepted 47ms 328.0 KiB
#9 Accepted 49ms 768.0 KiB
#10 Accepted 47ms 860.0 KiB
#11 Accepted 479ms 652.0 KiB
#12 Accepted 1597ms 1.504 MiB
#13 Accepted 314ms 1.5 MiB
#14 Accepted 16ms 1.324 MiB
#15 Accepted 509ms 1.496 MiB
#16 Accepted 17ms 1.527 MiB
#17 Accepted 19ms 1.5 MiB
#18 Accepted 1590ms 1.504 MiB
#19 Accepted 25ms 1.277 MiB
#20 Accepted 1400ms 1.527 MiB
#21 Time Exceeded ≥2098ms ≥4.57 MiB
#22 Time Exceeded ≥2095ms ≥4.324 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  long double
#define ull unsigned long long
#define PI acos(-1.0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define rev_str(str) reverse(str.begin(),str.end());
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i =a ;i<b;i++)
#define per(i,b,a) for(ll i=b;i>=a;i--)
#define all(a)  (a.begin(),a.end())
#define srt(a) sort(all(a))
#define rsrt(a) sort(a.rbegin(),a.rend())
bool sortByValue(const pair<int,int>& a,const pair<int,int>& b){
    return a.second > b.second;
}
const ll N=10e5+5;

ll gcd(ll a,ll b){
    return b == 0 ? a : gcd(b, a%b);
}

ll lcm(ll a,ll b){
    return (a / gcd(a, b)) * b;
}


void solve(){
    ll n,m;cin>>n>>m;
    char p[n][m];
    map<char,ll>mp;
    map<char,ll>f;
    rep(i,0,n){
        rep(j,0,m){
            cin>>p[i][j];
            if(p[i][j]=='+') f[p[i][j]]++;
        }
    }
    //cout<<f['+']<<endl;
    // if(f['+']==(n*m)){
    //     ll ki = min(n,m);
    //     cout<<ki+(ki-1)<<endl;return;
    // }
    //set<ll>q;
    ll mx =0;
    rep(i,0,n){
        rep(j,0,m){
            if(p[i][j]=='+'){
                ll left = i;
                ll right = m;
                ll up = 0;
                ll down = n;
                ll one=0;
                ll two=0;
                ll three=0;
                ll four=0;
                rep(k,i+1,n){
                    if(p[k][j]=='+'){
                        one++;
                    }
                    else{
                        break;
                    }
                }
                per(k,i-1,0){
                    if(p[k][j]=='+'){
                        two++;
                    }
                    else{
                        break;
                    }
                }
                rep(k,j+1,m){
                    if(p[i][k]=='+'){
                        three++;
                    }
                    else{
                        break;
                    }
                }
                per(k,j-1,0){
                    if(p[i][k]=='+'){
                        four++;
                    }
                    else{
                        break;
                    }
                }
                ll ki = min(one,two);
                ll ji = min(three,four);
                ki*=2;
                ki++;
                ji*=2;
                ji++;
                ll mn = min(ki,ji);
                mx = max(mn,mx);
                //cout<<ki<<" "<<ji<<endl;
            }
        }
    }
    cout<<max(0LL,mx+(mx-1))<<endl;

}

int main(){
    fast;
    ll t=1;cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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 07:45:48
Judged At
2024-12-09 07:45:48
Judged By
Score
60
Total Time
≥2098ms
Peak Memory
≥4.57 MiB