/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 540.0 KiB
#2 Wrong Answer 2ms 796.0 KiB

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;
        string s[n];
        for(i = 0; i < n; i++) {
            cin >> s[i];
            // 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] == '+') {

                    // 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] == '+') {
                    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 02:15:09
Judged At
2024-12-08 02:15:09
Judged By
Score
0
Total Time
2ms
Peak Memory
796.0 KiB