/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 10ms 844.0 KiB
#3 Accepted 20ms 692.0 KiB
#4 Accepted 22ms 816.0 KiB
#5 Accepted 17ms 688.0 KiB
#6 Accepted 24ms 872.0 KiB
#7 Accepted 100ms 540.0 KiB
#8 Accepted 30ms 840.0 KiB
#9 Accepted 31ms 1.445 MiB
#10 Accepted 36ms 1.445 MiB
#11 Accepted 292ms 1.59 MiB
#12 Accepted 897ms 9.262 MiB
#13 Accepted 199ms 9.258 MiB
#14 Accepted 20ms 9.203 MiB
#15 Accepted 280ms 9.02 MiB
#16 Accepted 22ms 9.078 MiB
#17 Accepted 23ms 9.035 MiB
#18 Accepted 870ms 9.262 MiB
#19 Accepted 26ms 9.082 MiB
#20 Accepted 774ms 9.258 MiB
#21 Time Exceeded ≥2098ms ≥34.949 MiB
#22 Time Exceeded ≥2101ms ≥34.953 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];
            }
        }

        vector<vii> piche(n, vii(m, 0)), upore(n, vii(m, 0));

        ll ans = 0;
        for(i = 0; i < n; i++) {
            for(j = 0; j < m; j++) {
                if(s[i][j] == '+') {
                    if(j == 0)
                        piche[i][j] = 1;
                    else
                        piche[i][j] = piche[i][j - 1] + 1;

                    if(i == 0)
                        upore[i][j] = 1;
                    else
                        upore[i][j] = upore[i - 1][j] + 1;

                    ll mn = min(piche[i][j], upore[i][j]);
                    ll jj = j;
                    while(jj < m && s[i][jj] == '+') {
                        jj++;
                    }
                    mn = min(mn, jj - j);
                    ll ii = i;
                    while(ii < n && s[ii][j] == '+') {
                        ii++;
                    }
                    mn = min(mn, ii - i);
                    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:24:13
Judged At
2024-12-08 03:24:13
Judged By
Score
60
Total Time
≥2101ms
Peak Memory
≥34.953 MiB