/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Accepted 19ms 588.0 KiB
#3 Accepted 44ms 588.0 KiB
#4 Accepted 51ms 588.0 KiB
#5 Accepted 42ms 588.0 KiB
#6 Accepted 53ms 584.0 KiB
#7 Accepted 312ms 576.0 KiB
#8 Accepted 82ms 584.0 KiB
#9 Accepted 90ms 672.0 KiB
#10 Accepted 90ms 668.0 KiB
#11 Accepted 1049ms 664.0 KiB
#12 Time Exceeded ≥2079ms ≥1.531 MiB
#13 Accepted 179ms 1.535 MiB
#14 Accepted 22ms 1.535 MiB
#15 Accepted 232ms 1.535 MiB
#16 Accepted 25ms 1.531 MiB
#17 Accepted 25ms 1.531 MiB
#18 Time Exceeded ≥2090ms ≥1.312 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;
        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++;
                    }
                    // bug(ok,mid);
                    // return 0;
                    cur=0;
                    while(cur<=mid){
                        if(v[i][j-cur]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                    cur=0;
                    while(cur<=mid){
                        if(v[i+cur][j]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                    cur=0;
                    while(cur<=mid){
                        if(v[i-cur][j]!='+'){
                            ok=0;
                            break;
                        }
                        cur++;
                    }
                    if(ok)l=mid+1;
                    else r=mid-1;
                    if(ok)ans=max(ans,4*mid+1);
                }
            }
        }
        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:25:48
Judged At
2024-12-09 06:25:48
Judged By
Score
44
Total Time
≥2090ms
Peak Memory
≥1.535 MiB