/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 588.0 KiB
#2 Accepted 16ms 2.918 MiB
#3 Accepted 41ms 2.84 MiB
#4 Accepted 46ms 2.812 MiB
#5 Accepted 33ms 976.0 KiB
#6 Accepted 48ms 2.754 MiB
#7 Accepted 235ms 2.883 MiB
#8 Accepted 54ms 2.672 MiB
#9 Accepted 57ms 10.797 MiB
#10 Accepted 54ms 4.73 MiB
#11 Accepted 669ms 4.629 MiB
#12 Time Exceeded ≥2028ms ≥18.91 MiB
#13 Accepted 486ms 20.621 MiB
#14 Accepted 29ms 20.672 MiB
#15 Accepted 593ms 19.066 MiB
#16 Accepted 33ms 18.926 MiB
#17 Accepted 36ms 20.562 MiB
#18 Time Exceeded ≥2033ms ≥20.59 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 " "
ll n, k;
const int N = 20000, K = 20000;
char a[N][K];
ll clk(ll x, ll y)
{
    ll val = 1000000, mn = 0;
    ll 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 = x+1; i < n; i++)
    {
      
        if (a[i][y] == '+')
        {
            down++;
        }
        else
        {

            break;
        }
    }
     
val = min({left, right, up, down});

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

    cin >> n >> k;
    int c=0;

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

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

    {
        for (ll j = 1; j < k-1; j++)
        {
            if (a[i][j] == '+')
            {
              mx = max(mx, clk(i, j));
            }
            //  cout<<mx;
        }
    }
    if(c==1)cout<<"1\n";
    else
    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:57:47
Judged At
2024-12-09 08:57:48
Judged By
Score
44
Total Time
≥2033ms
Peak Memory
≥20.672 MiB