/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 11ms 3.027 MiB
#3 Accepted 30ms 2.824 MiB
#4 Accepted 35ms 2.77 MiB
#5 Accepted 25ms 2.777 MiB
#6 Accepted 36ms 3.027 MiB
#7 Accepted 155ms 2.777 MiB
#8 Accepted 38ms 3.027 MiB
#9 Accepted 40ms 10.777 MiB
#10 Accepted 38ms 4.527 MiB
#11 Accepted 423ms 4.863 MiB
#12 Accepted 1345ms 20.836 MiB
#13 Accepted 283ms 19.07 MiB
#14 Accepted 20ms 19.059 MiB
#15 Accepted 532ms 20.668 MiB
#16 Accepted 33ms 20.73 MiB
#17 Accepted 35ms 19.016 MiB
#18 Accepted 1927ms 18.906 MiB
#19 Accepted 38ms 20.633 MiB
#20 Accepted 1713ms 18.93 MiB
#21 Time Exceeded ≥2020ms ≥38.996 MiB
#22 Time Exceeded ≥2069ms ≥38.883 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;

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

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

    {
        for (ll 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:52:52
Judged At
2024-12-09 08:52:52
Judged By
Score
60
Total Time
≥2069ms
Peak Memory
≥38.996 MiB