/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 348.0 KiB
#2 Accepted 16ms 2.75 MiB
#3 Accepted 44ms 2.57 MiB
#4 Accepted 50ms 972.0 KiB
#5 Accepted 35ms 2.723 MiB
#6 Accepted 52ms 2.578 MiB
#7 Accepted 232ms 2.746 MiB
#8 Accepted 57ms 2.75 MiB
#9 Accepted 59ms 10.707 MiB
#10 Accepted 57ms 4.801 MiB
#11 Accepted 719ms 4.738 MiB
#12 Accepted 1314ms 18.859 MiB
#13 Accepted 284ms 20.715 MiB
#14 Accepted 19ms 20.844 MiB
#15 Accepted 482ms 18.871 MiB
#16 Accepted 33ms 20.672 MiB
#17 Accepted 35ms 20.562 MiB
#18 Accepted 1909ms 18.91 MiB
#19 Accepted 40ms 20.742 MiB
#20 Accepted 1320ms 20.656 MiB
#21 Time Exceeded ≥2098ms ≥38.77 MiB
#22 Time Exceeded ≥2094ms ≥38.996 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 , 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 = 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 09:01:13
Judged At
2024-12-09 09:01:13
Judged By
Score
60
Total Time
≥2098ms
Peak Memory
≥38.996 MiB