/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 584.0 KiB
#2 Accepted 11ms 788.0 KiB
#3 Accepted 31ms 760.0 KiB
#4 Accepted 35ms 576.0 KiB
#5 Accepted 25ms 572.0 KiB
#6 Accepted 37ms 516.0 KiB
#7 Accepted 173ms 560.0 KiB
#8 Accepted 39ms 572.0 KiB
#9 Accepted 38ms 840.0 KiB
#10 Accepted 39ms 796.0 KiB
#11 Accepted 490ms 668.0 KiB
#12 Accepted 1735ms 1.531 MiB
#13 Accepted 288ms 1.57 MiB
#14 Accepted 15ms 1.527 MiB
#15 Accepted 557ms 1.535 MiB
#16 Accepted 17ms 1.527 MiB
#17 Accepted 19ms 1.527 MiB
#18 Accepted 1629ms 1.531 MiB
#19 Accepted 21ms 1.527 MiB
#20 Accepted 1457ms 1.539 MiB
#21 Time Exceeded ≥2097ms ≥4.566 MiB
#22 Time Exceeded ≥2097ms ≥4.527 MiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll int
#define db long double
#define vii vector<ll>
#define pll pair<ll, ll>
#define F first
#define S second


const ll N = (ll) 3e5 + 5;
const ll mod = (ll) 1e9 + 7;
const ll inf = (ll) 1e18;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--) {
        ll a, b, c, i, j, k, m, n, o, x, y, z;
        cin >> n >> m;
        vector<vector<char>> s(n, vector<char>(m));
        for(i = 0; i < n; i++) {
            for(j = 0; j < m; j++) {
                cin >> s[i][j];
            }
        }

        ll ans = 0;
        for(i = 0; i < n; i++) {
            for(j = 0; j < m; j++) {
                if(s[i][j] == '+') {
                    ll mn = n + m + 1;
                    ll jj = j;
                    while(jj < m && s[i][jj] == '+') {
                        jj++;
                    }
                    mn = min(mn, jj - j);
                    jj = j;
                    while(jj >= 0 && s[i][jj] == '+') {
                        jj--;
                    }
                    mn = min(mn, j - jj);
                    ll ii = i;
                    while(ii < n && s[ii][j] == '+') {
                        ii++;
                    }
                    mn = min(mn, ii - i);
                    ii = i;
                    while(ii >= 0 && s[ii][j] == '+') {
                        ii--;
                    }
                    mn = min(mn, i - ii);
                    ans = max(ans, mn);
                }
            }
        }    
        cout << (ans == 0 ? 0 : (ans << 2) - 3) << "\n";
    }
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU Divisonal Contest Problem Testing Round
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-08 03:19:53
Judged At
2024-12-08 03:19:53
Judged By
Score
60
Total Time
≥2097ms
Peak Memory
≥4.566 MiB