/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 584.0 KiB
#2 Wrong Answer 11ms 1.027 MiB
#3 Wrong Answer 14ms 896.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;
        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) {
                    ll jj = j;
                    while(jj < m && s[i][jj] == '+')
                        jj++;

                    ulta[i][j] = (jj - 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 09:22:43
Judged At
2024-12-08 09:22:43
Judged By
Score
2
Total Time
14ms
Peak Memory
1.027 MiB