/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Wrong Answer 11ms 2.527 MiB
#3 Wrong Answer 30ms 2.527 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl << "\n"
#define yes << "YES\n"
#define no << "NO\n"
#define sp " "
int n, k;
const int N = 2000 + 5, K = 2000 + 5;
char a[N][K];
int clk(int x, int y)
{
    int val = 1000000, mn = 0;
    int left = 0, right = 0, up = 0, down = 0;
    //cout<<a[3][0] nl;
    for (int i = y - 1; i >= 0; i--)
    {
      
        if (a[x][i]=='+')
        {
            left++;
              
        }
        else
        {
           //  cout<<"lp lft \n";

            break;
        }
    }
    for (int i = y +1; i < k; i++)
    {
        //  cout<<"lp right \n";
        if (a[x][i] == '+')
        {
            right++;
        }
        else
        {
            break;
        }
    }
    for (int i = x - 1; i >= 0; i--)
    {
         // cout<<"lp up \n";
        if (a[i][y] == '+')
        {
            up++;
        }
        else
        {

            break;
        }
    }
    //cout<<y nl;
    for (int i = y ; i < n; i++)
    {
         //cout<<i nl;
       // cout<<"lp dwn \n";
        if (a[i][y] == '+')
        {
            down++;
        }
        else
        {

            break;
        }
    }
   // cout << "left:"<<left << " right: "<< right << " up:" << up << " down:" << down nl;
    val = min({left, right, up, down});

    return (val * 4) + 1;
}
void solve()
{

    cin >> n >> k;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            cin >> a[i][j];
        }
    }

    int mx = 0, cnt = 0;
    //clk(2, 3);
    for (int i = 0; i < n; i++)

    {
        for (int j = 0; j < k; j++)
        {
            if (a[i][j] == '+')
            {
               mx = max(mx, clk(i,j));
            }
            //  cout<<mx;
        }
    }
    cout << mx nl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin >> t;
    for (ll i = 0; i < t; i++)
        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 08:00:50
Judged At
2024-12-09 08:00:50
Judged By
Score
2
Total Time
30ms
Peak Memory
2.527 MiB