/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 808.0 KiB
#2 Accepted 10ms 796.0 KiB
#3 Accepted 29ms 744.0 KiB
#4 Accepted 32ms 796.0 KiB
#5 Accepted 24ms 756.0 KiB
#6 Accepted 34ms 540.0 KiB
#7 Accepted 152ms 760.0 KiB
#8 Accepted 38ms 540.0 KiB
#9 Accepted 38ms 1.277 MiB
#10 Accepted 37ms 1.066 MiB
#11 Accepted 453ms 1.027 MiB
#12 Accepted 1362ms 3.102 MiB
#13 Accepted 298ms 3.582 MiB
#14 Accepted 17ms 3.566 MiB
#15 Accepted 387ms 2.777 MiB
#16 Accepted 18ms 4.363 MiB
#17 Accepted 19ms 2.289 MiB
#18 Accepted 1365ms 3.383 MiB
#19 Accepted 21ms 2.527 MiB
#20 Accepted 1219ms 3.723 MiB
#21 Time Exceeded ≥2096ms ≥4.281 MiB
#22 Time Exceeded ≥2094ms ≥4.234 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 = x+1; 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});
//if(left!=0 and right!=0 and up!=0 and down!=0)
    //return left + right + down + up + 1;
    return (4*val)+1;
    //else return 0;
}
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),cout.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:21:43
Judged At
2024-12-09 08:21:43
Judged By
Score
60
Total Time
≥2096ms
Peak Memory
≥4.363 MiB