/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int tc;
    cin >> tc;
    // assert(tc >= 1 && tc <= 10);

    int total_cells = 0;

    while(tc--) {
        int n, m;
        cin >> n >> m;
        // assert(n >= 1 && n <= 2000);
        // assert(m >= 1 && m <= 2000);
        total_cells += n * m;
        vector<string>grid(n);
        for(int i = 0; i < n; i++) {
            cin >> grid[i];
            // cout << grid[i] << endl;
            // cout << grid[i].size() << endl;
        }
        int best = 0;
        vector<vector<int>> lc(n, vector<int>(m)), rc(n, vector<int>(m)), uc(n, vector<int>(m)), dc(n, vector<int>(m));
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if (grid[i][j] != '+') {
                    continue;
                }
                // cout << "here..." << endl;
                lc[i][j] = (j > 0 ? lc[i][j - 1] : 0) + 1;
                uc[i][j] = (i > 0 ? uc[i - 1][j] : 0) + 1;
            }
        }
        for(int i = n - 1; i >= 0; i--) {
            for(int j = m - 1; j >= 0; j--) {
                if (grid[i][j] != '+') {
                    continue;
                }
                rc[i][j] = (j + 1 < m ? rc[i][j + 1] : 0) + 1;
                dc[i][j] = (i + 1 < n ? lc[i + 1][j] : 0) + 1;

                int side = min({lc[i][j], rc[i][j], uc[i][j], dc[i][j]});
                // cout << "side: " << side << endl;
                best = max(best, (side - 1) * 4 + 1);
            }
        }

        cout << best << endl;
    }

    assert(total_cells >= 1 && total_cells <= 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-07 19:25:48
Judged At
2024-12-07 19:25:48
Judged By
Score
0
Total Time
2ms
Peak Memory
540.0 KiB