/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 7ms 796.0 KiB
#3 Wrong Answer 19ms 744.0 KiB

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;
    for (int i = y - 1; i >= 0; i--)
    {
        if (a[x][i] == '+')
        {
            left++;
        }
        else
        {

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

            break;
        }
    }
    for (int i = y + 1; i < n; i++)
    {
        if (a[i][y] == '+')
        {
            down++;
        }
        else
        {

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

    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(1,1);
    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 07:24:02
Judged At
2024-12-09 07:24:02
Judged By
Score
2
Total Time
19ms
Peak Memory
796.0 KiB