/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 556.0 KiB
#2 Accepted 7ms 540.0 KiB
#3 Accepted 13ms 540.0 KiB
#4 Accepted 14ms 564.0 KiB
#5 Accepted 10ms 540.0 KiB
#6 Accepted 15ms 568.0 KiB
#7 Accepted 75ms 572.0 KiB
#8 Accepted 38ms 572.0 KiB
#9 Accepted 22ms 796.0 KiB
#10 Accepted 25ms 540.0 KiB
#11 Accepted 164ms 796.0 KiB
#12 Accepted 591ms 1.504 MiB
#13 Accepted 20ms 1.5 MiB
#14 Accepted 14ms 1.527 MiB
#15 Accepted 17ms 1.527 MiB
#16 Accepted 15ms 1.32 MiB
#17 Accepted 16ms 1.684 MiB
#18 Accepted 640ms 1.5 MiB
#19 Accepted 18ms 1.277 MiB
#20 Accepted 495ms 1.527 MiB
#21 Time Exceeded ≥2101ms ≥4.359 MiB
#22 Accepted 175ms 4.5 MiB
#23 Accepted 161ms 4.371 MiB
#24 Accepted 164ms 4.527 MiB
#25 Accepted 89ms 4.277 MiB
#26 Accepted 796ms 4.527 MiB
#27 Accepted 162ms 4.375 MiB
#28 Accepted 121ms 4.367 MiB
#29 Accepted 1308ms 4.527 MiB
#30 Time Exceeded ≥2037ms ≥4.445 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 = 1;
    int mx_val = n + m - 1;
    for (int i = 2; i < n; i++)
    {
        for (int j = 2; 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 08:00:33
Judged At
2024-12-09 08:00:33
Judged By
Score
92
Total Time
≥2101ms
Peak Memory
≥4.527 MiB