/ SeriousOJ /

Record Detail

Memory Exceeded


  
# Status Time Cost Memory Cost
#1 Memory Exceeded ≥183ms ≥256.016 MiB
#2 Memory Exceeded ≥185ms ≥256.016 MiB

Code

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define yes cout << "YES" << "\n";
#define no cout << "NO" << "\n";
#define fri(a, b) for (ll i = a; i < b; i++)
#define frj(a, b) for (ll j = a; j < b; j++)
#define frk(a, b) for (ll k = a; k < b; k++)
#define rfri(a, b) for (ll i = a; i >= b; i--)

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll T = 1;
    cin >> T;
    while (T--)
    {
        ll n, i, j, k, cnt = 0, mx = 0, m, p;
        scanf("%lld%lld",&n,&k);
        char s[n][k];
        for (i = 0; i < n; i++)
        {
            for(j=0;j<k;j++){
               cin >> s[i][j];
            }
        }
       // mx=max(n,k);
        m = n/2;
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < k; j++)
            {
                if (s[i][j] == '+')
                {
                    cnt = 1;
                    for (p = 1; p <= m; p++)
                    {

                        if (i - p >= 0 && j - p >= 0 && j + p < k && i + p < n)
                        {

                            if (s[i - p][j] == '+' && s[i + p][j] == '+' && s[i][j + p] == '+' && s[i][j - p] == '+')
                            {
                                cnt += 4;
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    mx = max(mx, cnt);
                }
            }
        }
      printf("%lld\n",mx);
    }
}

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:44:26
Judged At
2024-12-09 08:44:26
Judged By
Score
0
Total Time
≥185ms
Peak Memory
≥256.016 MiB