/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 10ms 540.0 KiB
#3 Accepted 33ms 588.0 KiB
#4 Accepted 35ms 784.0 KiB
#5 Accepted 23ms 768.0 KiB
#6 Accepted 38ms 816.0 KiB
#7 Accepted 234ms 540.0 KiB
#8 Accepted 34ms 540.0 KiB
#9 Accepted 36ms 584.0 KiB
#10 Accepted 34ms 852.0 KiB
#11 Accepted 778ms 664.0 KiB
#12 Time Exceeded ≥2090ms ≥1.32 MiB
#13 Accepted 140ms 1.527 MiB
#14 Accepted 15ms 1.527 MiB
#15 Accepted 26ms 1.527 MiB
#16 Accepted 15ms 1.754 MiB
#17 Accepted 16ms 1.504 MiB
#18 Time Exceeded ≥2089ms ≥1.527 MiB

Code

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define bug(a) cout<<#a<<" : "<<a<<endl;
#define bug2(a,b) cout<<#a<<" : "<<a<<"\t"<<#b<<" : "<<b<<endl;


signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t=1;cin>>t;
    while(t--){
        int n,m;cin>>n>>m;
        vector<vector<char>>v(n,vector<char>(m));
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cin>>v[i][j];
            }
        }
        // for(int i=0;i<n;i++){
        //     for(int j=0;j<m;j++){
        //         if(v[i][j]==' ')continue;
        //         cout<<v[i][j]<<' ';
        //     }
        //     cout<<endl;
        // }
        // return 0;
        int ans=0;
        bool got=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(v[i][j]!='+')continue;
                int l=0,r=min({i,j,n-i-1,m-j-1});
                // bug("hi")
                while(l<=r){
                    bool ok=1;
                    int mid=(l+r)/2;
                    int cur=0;
                    while(cur<=mid){
                        if(v[i][j+cur]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                    if(ok==0)goto niche;
                    // bug(ok,mid);
                    // return 0;
                    cur=0;
                    while(cur<=mid){
                        if(v[i][j-cur]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                     if(ok==0)goto niche;
                    cur=0;
                    while(cur<=mid){
                        if(v[i+cur][j]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                     if(ok==0)goto niche;
                    cur=0;
                    while(cur<=mid){
                        if(v[i-cur][j]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                     if(ok==0)goto niche;
                    niche:
                    if(ok)l=mid+1;
                    else r=mid-1;
                    if(ok)ans=max(ans,4*mid+1);
                    if(ans==n+m-1)
                    {
                        got=1;
                    }
                    if(got)break;
                }
                if(got)break;
            }
            if(got)break;
        }
        cout<<ans<<endl;
    }
    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 06:30:56
Judged At
2024-12-09 06:30:57
Judged By
Score
44
Total Time
≥2090ms
Peak Memory
≥1.754 MiB