/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 7ms 596.0 KiB
#3 Accepted 12ms 972.0 KiB
#4 Accepted 12ms 860.0 KiB
#5 Accepted 12ms 944.0 KiB
#6 Accepted 12ms 836.0 KiB
#7 Accepted 69ms 976.0 KiB
#8 Accepted 25ms 588.0 KiB
#9 Accepted 24ms 1.02 MiB
#10 Accepted 24ms 796.0 KiB
#11 Accepted 136ms 4.25 MiB
#12 Accepted 451ms 19.582 MiB
#13 Accepted 15ms 1.32 MiB
#14 Accepted 14ms 1.754 MiB
#15 Accepted 16ms 1.32 MiB
#16 Accepted 15ms 1.527 MiB
#17 Accepted 15ms 1.766 MiB
#18 Accepted 405ms 19.871 MiB
#19 Accepted 18ms 1.527 MiB
#20 Accepted 343ms 19.621 MiB
#21 Time Exceeded ≥2082ms ≥70.609 MiB
#22 Accepted 163ms 70.625 MiB
#23 Accepted 169ms 70.707 MiB
#24 Accepted 165ms 70.664 MiB
#25 Accepted 96ms 7.473 MiB
#26 Accepted 535ms 70.539 MiB
#27 Accepted 191ms 70.621 MiB
#28 Accepted 158ms 70.578 MiB
#29 Accepted 891ms 70.535 MiB
#30 Accepted 1230ms 70.66 MiB

Code

/*
 *Copyright (c) Swadheen Islam Robi (SIR01)
 *Created on Tue Dec 10 2024 3:03:19 PM
 */

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pie 2*(acos(0.0))
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define endl "\n"
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define ALLAHU_AKBAR ios::sync_with_stdio(false); cin.tie(nullptr);

void sir() {
    ll n, m;
    cin >> n >> m;

    vector<vector<char>> grid(n + 2, vector<char>(m + 2, '.'));

    bool got = false;

    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            cin >> grid[i][j];
            if (!got && grid[i][j] == '+') {
                got = true;
            }
        }
    }

    if (!got) {
        cout << 0 << endl;
        return;
    }

    vector<pair<ll, ll>> point;
    for (ll i = 2; i < n; i++) {
        for (ll j = 2; j < m; j++) {
            if (grid[i][j] == '+' &&
                grid[i - 1][j] == '+' && grid[i + 1][j] == '+' &&
                grid[i][j - 1] == '+' && grid[i][j + 1] == '+') {
                point.emplace_back(i, j);
            }
        }
    }

    if (point.empty()) {
        cout << 1 << endl;
        return;
    }

    ll mx = -1;
    ll pmx = (min(n, m) * 2) - 1;

    for (const auto &p : point) {
        ll f = p.first;
        ll s = p.second;
        ll c = 0;

        while (grid[f - c][s] == '+' && grid[f + c][s] == '+' &&
               grid[f][s - c] == '+' && grid[f][s + c] == '+') {
            c++;
        }

        ll sz = (4 * (c - 1)) + 1;
        mx = max(mx, sz);

        if (mx == pmx) {
            cout << mx << endl;
            return;
        }
    }

    cout << mx << endl;
}

int main() {
    ALLAHU_AKBAR

    ll t;
    cin >> t;
    while (t--) {
        sir();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU IUJPC : Sylhet Division 2024 Replay Contest
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-10 10:46:31
Judged At
2024-12-10 10:46:31
Judged By
Score
96
Total Time
≥2082ms
Peak Memory
≥70.707 MiB