/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 50ms 540.0 KiB
#3 Wrong Answer 51ms 540.0 KiB

Code

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;

        char arr[n][m];
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                cin >> arr[i][j];
            }
        }

        int highest_pluses = 0;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(arr[i][j] =='+') {
                    int curr_pluses = 1;
                    int top = 0, bottom = 0, left = 0, right = 0;
                    // top
                    for(int k = i - 1; k >= 0; k--) {
                        if(arr[k][j] == '+') {
                            top++;
                        }
                    }
                    // bottom 
                    for(int k = i + 1; k < n; k++) {
                        if(arr[k][j] == '+') {
                            bottom++;
                        }
                    }
                    // left 
                    for(int k = j - 1; k >= 0; k--) {
                        if(arr[i][k] == '+') {
                            left++;
                        }
                    }
                    // right 
                    for(int k = j + 1; k < m; k++) {
                        if(arr[i][k] == '+') {
                            right++;
                        }
                    }

                    curr_pluses += 4 * min({top, bottom, left, right});

                    highest_pluses = max(curr_pluses, highest_pluses);
                }
            }
        }
        cout << highest_pluses << endl;
    } 
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 07:44:56
Judged At
2024-12-09 07:44:56
Judged By
Score
2
Total Time
51ms
Peak Memory
540.0 KiB