/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 556.0 KiB
#2 Accepted 9ms 332.0 KiB
#3 Wrong Answer 13ms 540.0 KiB
#4 Wrong Answer 14ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define ll long long
#define endl '\n'
#define gap " "
#define bug(a) cerr<<#a<<":"<<a<<endl;
#define gcd __gcd(a,b)
#define lcm (a*b)/(__gcd(a,b))
#define pb push_back
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
const double pi=acos(-1);
const ll mod=1000000007;
#define tc ll t;cin>>t;while(t--)
int main()
{
    optimize()
    tc
    {
        ll n,m;
        cin>>n>>m;
        char arr[n][m];
        ll i,j,k,l,n1,n2;
        ll maxi=0;
        ll cnt=0;
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                cin>>arr[i][j];
                if(arr[i][j]=='+')cnt++;
            }
        }
        if(cnt==(n*m))cout<<(n+m)-1<<endl;
        else{
        for(i=0;i<n;i++)
        {
            
            for(j=0;j<m;j++)
            {
                if(arr[i][j]=='+')
                {
                
                    ll c1=0;
                    for(k=i+1, l=i-1, n1=j+1, n2=j-1;k<n && l>=0 && n1<m && n2>=0;k++, l--, n1++, n2--)
                    {
                        if(arr[k][j]!='+' || k>=n)
                        {
                            break;
                        }
                        if(arr[l][j]!='+' || l<0)
                        {
                            break;
                        }
                         if(arr[i][n1]!='+' || n1>=m)
                        {
                            break;
                        }
                         if(arr[i][n2]!='+' || n2<0)
                        {
                            break;
                        }
                        c1++;
                    }
                    ll check=(c1*4)+1;
                    maxi=max(check,maxi);
                }
            }
        }
        cout<<maxi<<endl;
        }
        
    }
}

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:44:06
Judged At
2024-12-09 06:44:06
Judged By
Score
4
Total Time
14ms
Peak Memory
556.0 KiB