/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 380.0 KiB
#2 Accepted 11ms 332.0 KiB
#3 Accepted 17ms 328.0 KiB
#4 Accepted 19ms 564.0 KiB
#5 Accepted 16ms 564.0 KiB
#6 Accepted 18ms 564.0 KiB
#7 Accepted 105ms 568.0 KiB
#8 Accepted 37ms 540.0 KiB
#9 Accepted 37ms 660.0 KiB
#10 Accepted 37ms 584.0 KiB
#11 Accepted 263ms 660.0 KiB
#12 Accepted 956ms 1.5 MiB
#13 Accepted 24ms 1.492 MiB
#14 Accepted 21ms 1.32 MiB
#15 Accepted 24ms 1.504 MiB
#16 Accepted 21ms 1.5 MiB
#17 Accepted 21ms 1.32 MiB
#18 Accepted 950ms 1.504 MiB
#19 Accepted 25ms 1.504 MiB
#20 Accepted 492ms 1.5 MiB
#21 Time Exceeded ≥2092ms ≥4.324 MiB
#22 Accepted 138ms 4.371 MiB
#23 Accepted 139ms 4.328 MiB
#24 Accepted 145ms 4.371 MiB
#25 Accepted 90ms 4.527 MiB
#26 Accepted 663ms 4.367 MiB
#27 Accepted 157ms 4.527 MiB
#28 Accepted 122ms 4.434 MiB
#29 Accepted 1213ms 4.527 MiB
#30 Accepted 1598ms 4.367 MiB

Code

#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define print(v) for(auto data : v) cout << data << " "; cout << endl;
using namespace std;
void solve()
{
    int n, m;
    cin >> n >> m; 
    char mat[n+1][m+1];
    bool isFound = false;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> mat[i][j];
            if(mat[i][j] == '+') isFound = true;
        }
    }
    if(isFound == false)
    {
        cout << 0 << endl; return;
    }
    int mx = 0;
    int mx_val = min(n, m) + min(n, m) - 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int temp = 1;
            int cnt = 0;
            if(mat[i][j] == '+')
            {
                while (i-1-cnt >= 1 && i-1-cnt <= n && 
                i+1+cnt >= 1 && i+1+cnt <= n &&
                j-1-cnt >= 1 && j-1-cnt <= m && 
                j+1+cnt >= 1 && j+1+cnt <= m
                && mat[i][j-1-cnt] == '+' && mat[i][j+1+cnt] == '+' &&
                mat[i-1-cnt][j] == '+' && mat[i+1+cnt][j] == '+')
                {
                    cnt++, temp += 4; 
                }
                mx = max(mx, temp);
                if(mx == mx_val) 
                {
                    cout << mx << endl; return;
                }
            }
        }
    }
    cout << mx << endl;
}
int main ()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int t; cin >> t;
    // int t = 1;
    while (t--) 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 07:53:02
Judged At
2024-12-09 07:53:02
Judged By
Score
96
Total Time
≥2092ms
Peak Memory
≥4.527 MiB