/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 12ms 736.0 KiB
#3 Accepted 8ms 796.0 KiB
#4 Accepted 8ms 796.0 KiB
#5 Accepted 10ms 812.0 KiB
#6 Accepted 8ms 796.0 KiB
#7 Accepted 21ms 796.0 KiB
#8 Accepted 39ms 744.0 KiB
#9 Accepted 47ms 2.23 MiB
#10 Accepted 46ms 2.188 MiB
#11 Accepted 29ms 2.195 MiB
#12 Accepted 35ms 16.77 MiB
#13 Accepted 34ms 16.789 MiB
#14 Accepted 30ms 16.812 MiB
#15 Accepted 34ms 16.855 MiB
#16 Accepted 31ms 16.816 MiB
#17 Accepted 33ms 17.02 MiB
#18 Accepted 36ms 16.793 MiB
#19 Accepted 41ms 16.77 MiB
#20 Accepted 37ms 17.02 MiB
#21 Accepted 190ms 65.832 MiB
#22 Accepted 187ms 65.77 MiB
#23 Accepted 190ms 65.695 MiB
#24 Accepted 182ms 65.824 MiB
#25 Accepted 212ms 65.699 MiB
#26 Accepted 187ms 65.699 MiB
#27 Accepted 190ms 65.812 MiB
#28 Accepted 194ms 65.652 MiB
#29 Accepted 195ms 65.547 MiB
#30 Accepted 192ms 65.52 MiB

Code

/*
    Author    : MishkatIT
    Created   : Tuesday 10-12-2024 16:27:09
*/

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

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const int inf = 1e9;
const ll linf = 1e18;

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

    int tc;
    cin >> tc;
    while (tc--) {
        int n, m;
        cin >> n >> m;
        int f = 0;
        vector<vector<char>> v(n, vector<char>(m));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cin >> v[i][j];
                f |= (v[i][j] == '+');
            }
        }
        vector<vector<pair<int, int>>> ans(n, vector<pair<int, int>>(m));
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < m; j++) {
                if (v[i][j] == '+') {
                    ans[i][j].first = cnt;
                    cnt++;
                } else cnt = 0;
            }
            cnt = 0;
            for (int j = m - 1; j >= 0; j--) {
                if (v[i][j] == '+') {
                    ans[i][j].second = cnt;
                    cnt++;
                } else cnt = 0;
            }
        }
        vector<vector<pair<int, int>>> bns(n, vector<pair<int, int>>(m));
        for (int j = 0; j < m; j++) {
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                if (v[i][j] == '+') {
                    bns[i][j].first = cnt;
                    cnt++;
                } else cnt = 0;
            }
            cnt = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (v[i][j] == '+') {
                    bns[i][j].second = cnt;
                    cnt++;
                } else cnt = 0;
            }
        }
        int mx = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                mx= max (mx, min({ans[i][j].first, ans[i][j].second, bns[i][j].first, bns[i][j].second}));
            }
        }
        cout << mx * 4 + f  << '\n';
    }
    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 12:48:02
Judged At
2024-12-10 12:48:02
Judged By
Score
100
Total Time
212ms
Peak Memory
65.832 MiB