/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 11ms 876.0 KiB
#3 Accepted 8ms 936.0 KiB
#4 Accepted 9ms 984.0 KiB
#5 Accepted 11ms 952.0 KiB
#6 Accepted 9ms 868.0 KiB
#7 Accepted 32ms 1.027 MiB
#8 Accepted 45ms 912.0 KiB
#9 Accepted 49ms 3.789 MiB
#10 Accepted 50ms 3.75 MiB
#11 Accepted 39ms 3.918 MiB
#12 Accepted 59ms 32.27 MiB
#13 Accepted 48ms 32.344 MiB
#14 Accepted 39ms 32.078 MiB
#15 Accepted 54ms 32.27 MiB
#16 Accepted 39ms 32.473 MiB
#17 Accepted 41ms 32.207 MiB
#18 Accepted 57ms 32.105 MiB
#19 Accepted 51ms 32.43 MiB
#20 Accepted 59ms 32.551 MiB
#21 Accepted 331ms 127.0 MiB
#22 Accepted 276ms 127.145 MiB
#23 Accepted 324ms 127.145 MiB
#24 Accepted 276ms 127.141 MiB
#25 Accepted 261ms 126.957 MiB
#26 Accepted 316ms 126.953 MiB
#27 Accepted 276ms 127.145 MiB
#28 Accepted 269ms 127.09 MiB
#29 Accepted 317ms 127.141 MiB
#30 Accepted 323ms 127.094 MiB

Code

/**
 *    author:   Binoy Barman
 *    created:  2024-12-10 16:48:55
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "debug/whereisit.hpp"
#else
#define dbg(...) 42
#endif
#define int long long

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    Too_Many_Jobs {
        int n, m;
        cin >> n >> m;
        vector<vector<char>> g(n + 2, vector<char>(m + 2, '#'));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                cin >> g[i][j];
            }
        }
        vector<vector<array<int, 4>>> a(n + 2, vector<array<int, 4>>(m + 2, {0, 0, 0, 0}));
        for (int i = 1; i <= n; i++) {
            int l = 1, r = 1;
            while(l <= m) {
                while(l <= m && g[i][l] == '-') l++;
                if(l > m) continue;
                r = l;
                while(r < m && g[i][r + 1] == '+') r++;
                for (int j = l; j <= r; j++) {
                    a[i][j][0] = l;
                    a[i][j][1] = r;
                }
                l = r + 1;
            }
        }
        for (int j = 1; j <= m; j++) {
            int l = 1, r = 1;
            while(l <= n) {
                while(l <= n && g[l][j] == '-') l++;
                if(l > n) continue;
                r = l;
                while(r < n && g[r + 1][j] == '+') r++;
                for (int i = l; i <= r; i++) {
                    a[i][j][2] = l;
                    a[i][j][3] = r;
                }
                l = r + 1;
            }
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) if(g[i][j] == '+') {
                auto c = a[i][j];
                int cur = min({j - c[0], c[1] - j, i - c[2], c[3] - i});
                ans = max(ans, 1 + cur * 4);
            }
        }
        cout << ans << nl;
    }
    
    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 11:15:35
Judged At
2024-12-10 11:15:35
Judged By
Score
100
Total Time
331ms
Peak Memory
127.145 MiB