/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 13ms 752.0 KiB
#3 Accepted 31ms 580.0 KiB
#4 Wrong Answer 35ms 540.0 KiB

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:23:22
Judged At
2024-12-09 06:23:22
Judged By
Score
4
Total Time
35ms
Peak Memory
752.0 KiB