/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 11ms 940.0 KiB
#3 Accepted 9ms 1.023 MiB
#4 Accepted 9ms 1008.0 KiB
#5 Accepted 11ms 1.18 MiB
#6 Accepted 12ms 1004.0 KiB
#7 Accepted 30ms 1.066 MiB
#8 Accepted 37ms 1.066 MiB
#9 Accepted 46ms 3.906 MiB
#10 Accepted 45ms 3.961 MiB
#11 Accepted 36ms 3.719 MiB
#12 Accepted 43ms 32.02 MiB
#13 Accepted 42ms 32.27 MiB
#14 Accepted 41ms 32.02 MiB
#15 Accepted 43ms 32.031 MiB
#16 Accepted 49ms 32.047 MiB
#17 Accepted 44ms 32.047 MiB
#18 Accepted 45ms 32.02 MiB
#19 Accepted 46ms 32.074 MiB
#20 Accepted 44ms 32.02 MiB
#21 Accepted 171ms 127.02 MiB
#22 Accepted 174ms 126.949 MiB
#23 Accepted 173ms 126.867 MiB
#24 Accepted 172ms 126.941 MiB
#25 Accepted 200ms 126.945 MiB
#26 Accepted 171ms 126.828 MiB
#27 Accepted 175ms 126.973 MiB
#28 Accepted 176ms 126.961 MiB
#29 Accepted 172ms 126.867 MiB
#30 Accepted 172ms 126.816 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;
    ll lim = 0;
    while(t--) {
        ll a, b, c, i, j, k, m, n, o, x, y, z;
        cin >> n >> m;
        lim += (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] == '+') {
                    ll jj = j;
                    while(jj < m && s[i][jj] == '+')
                        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";
    }

    assert(lim <= 4000000);
}

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:07:10
Judged At
2024-12-08 03:07:10
Judged By
Score
100
Total Time
200ms
Peak Memory
127.02 MiB