/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 11ms 940.0 KiB
#3 Accepted 9ms 944.0 KiB
#4 Accepted 9ms 1020.0 KiB
#5 Accepted 10ms 1.004 MiB
#6 Accepted 9ms 972.0 KiB
#7 Accepted 29ms 912.0 KiB
#8 Accepted 37ms 908.0 KiB
#9 Accepted 44ms 3.793 MiB
#10 Accepted 43ms 3.797 MiB
#11 Accepted 36ms 3.734 MiB
#12 Accepted 42ms 32.07 MiB
#13 Accepted 41ms 32.27 MiB
#14 Accepted 41ms 32.457 MiB
#15 Accepted 43ms 32.031 MiB
#16 Accepted 45ms 32.148 MiB
#17 Accepted 41ms 32.043 MiB
#18 Accepted 41ms 32.02 MiB
#19 Accepted 44ms 32.062 MiB
#20 Accepted 42ms 32.102 MiB
#21 Accepted 169ms 127.02 MiB
#22 Accepted 171ms 126.828 MiB
#23 Accepted 176ms 127.199 MiB
#24 Accepted 169ms 126.93 MiB
#25 Accepted 198ms 126.824 MiB
#26 Accepted 170ms 126.871 MiB
#27 Accepted 172ms 126.988 MiB
#28 Accepted 181ms 126.812 MiB
#29 Accepted 169ms 127.02 MiB
#30 Accepted 172ms 127.031 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];
            }
            // cerr << s[i] << "\n";
        }

        vector<vii> shoja, ulta, dan, bam;
        shoja.assign(n, vii(m, 0));
        ulta = dan = bam = shoja;
        // cerr << dan.size() << "\n";

        for(i = 0; i < n; i++) {
            for(j = 0; j < m; j++) {
                // cout << s[i][j] << "\n";
                if(s[i][j] == 43) {
                    ll jj = j;
                    while(jj < m && s[i][jj] == '+')
                        jj++; 
                    shoja[i][j] = jj;

                    shoja[i][j] -= jj;

                    // cerr << i << " " << j << "\n";
                    if(i == 0)
                        shoja[i][j] = 1;
                    else
                        shoja[i][j] = shoja[i - 1][j] + 1;
                    if(j == 0)
                        bam[i][j] = 1;
                    else
                        bam[i][j] = bam[i][j - 1] + 1;
                } else {
                    shoja[i][j] = 0;
                    bam[i][j] = 0;
                }
            }
        }
        // cerr << shoja[2][1] << "\n";
        for(i = n - 1; i >= 0; i--) {
            for(j = m - 1; j >= 0; j--) {
                if(s[i][j] == 43) {
                    if(i == n - 1)
                        ulta[i][j] = 1;
                    else
                        ulta[i][j] = ulta[i + 1][j] + 1;
                    if(j == m - 1)
                        dan[i][j] = 1;
                    else
                        dan[i][j] = dan[i][j + 1] + 1;
                } else {
                    ulta[i][j] = 0;
                    dan[i][j] = 0;
                }
            }
        }

        ll ans = 0;
        for(i = 0; i < n; i++) {
            for(j = 0; j < m; j++) {
                ans = max(ans, 4 * min({shoja[i][j], ulta[i][j], dan[i][j], bam[i][j]}) - 3);
            }
        }
        cout << ans << "\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 09:20:28
Judged At
2024-12-08 09:20:28
Judged By
Score
100
Total Time
198ms
Peak Memory
127.199 MiB