/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Accepted 16ms 588.0 KiB
#3 Accepted 45ms 584.0 KiB
#4 Accepted 49ms 572.0 KiB
#5 Accepted 36ms 576.0 KiB
#6 Accepted 57ms 576.0 KiB
#7 Accepted 262ms 568.0 KiB
#8 Accepted 57ms 576.0 KiB
#9 Accepted 52ms 672.0 KiB
#10 Accepted 55ms 664.0 KiB
#11 Accepted 749ms 668.0 KiB
#12 Time Exceeded ≥2059ms ≥1.32 MiB
#13 Accepted 430ms 1.535 MiB
#14 Accepted 29ms 1.328 MiB
#15 Accepted 934ms 1.527 MiB
#16 Accepted 24ms 1.324 MiB
#17 Accepted 32ms 1.527 MiB
#18 Time Exceeded ≥2002ms ≥1.32 MiB

Code

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

#define ll long long
#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:18:39
Judged At
2024-12-08 03:18:39
Judged By
Score
44
Total Time
≥2059ms
Peak Memory
≥1.535 MiB