/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 8ms 564.0 KiB
#3 Accepted 10ms 752.0 KiB
#4 Accepted 11ms 572.0 KiB
#5 Accepted 10ms 540.0 KiB
#6 Accepted 11ms 540.0 KiB
#7 Accepted 63ms 568.0 KiB
#8 Accepted 26ms 540.0 KiB
#9 Accepted 26ms 840.0 KiB
#10 Accepted 26ms 796.0 KiB
#11 Accepted 135ms 540.0 KiB
#12 Accepted 554ms 1.5 MiB
#13 Accepted 17ms 1.527 MiB
#14 Accepted 15ms 1.504 MiB
#15 Accepted 17ms 1.547 MiB
#16 Accepted 15ms 1.508 MiB
#17 Accepted 15ms 1.504 MiB
#18 Accepted 483ms 1.527 MiB
#19 Accepted 19ms 1.504 MiB
#20 Accepted 401ms 1.496 MiB
#21 Time Exceeded ≥2091ms ≥4.277 MiB
#22 Accepted 137ms 4.527 MiB
#23 Accepted 143ms 4.371 MiB
#24 Accepted 141ms 4.27 MiB
#25 Accepted 102ms 4.5 MiB
#26 Accepted 1121ms 4.363 MiB
#27 Accepted 260ms 4.359 MiB
#28 Accepted 203ms 4.367 MiB
#29 Accepted 1601ms 4.367 MiB
#30 Time Exceeded ≥2027ms ≥4.148 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,mn;
        cin >> n >> k;
        char s[n][k];
        ll x=min(n,k);
        x=(x*2)-1;
        for (i = 0; i < n; i++)
        {
            for(j=0;j<k;j++){
                cin>>s[i][j]; 
            }
        }
        mn=min(n,k);
        m = mn/2;
       // m=min(m,500LL);
        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);
                    if(mx==x){
                        break;
                    }
                }
                 if(mx==x){
                        break;
                    }
            }
             if(mx==x){
                        break;
                    }
        }
        cout << mx << "\n";
    }
}

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:30:21
Judged At
2024-12-09 09:30:21
Judged By
Score
92
Total Time
≥2091ms
Peak Memory
≥4.527 MiB