/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 584.0 KiB
#2 Accepted 22ms 540.0 KiB
#3 Accepted 42ms 512.0 KiB
#4 Accepted 47ms 744.0 KiB
#5 Accepted 40ms 540.0 KiB
#6 Accepted 49ms 540.0 KiB
#7 Accepted 223ms 588.0 KiB
#8 Accepted 83ms 772.0 KiB
#9 Accepted 84ms 796.0 KiB
#10 Accepted 83ms 540.0 KiB
#11 Accepted 509ms 812.0 KiB
#12 Accepted 1669ms 1.473 MiB
#13 Accepted 334ms 1.477 MiB
#14 Accepted 64ms 1.324 MiB
#15 Accepted 608ms 1.527 MiB
#16 Accepted 65ms 1.477 MiB
#17 Accepted 79ms 1.504 MiB
#18 Accepted 1705ms 1.465 MiB
#19 Accepted 68ms 1.562 MiB
#20 Accepted 1475ms 1.477 MiB
#21 Time Exceeded ≥2095ms ≥4.574 MiB
#22 Time Exceeded ≥2099ms ≥4.527 MiB

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++;
                        }
                        else {
                            break;
                        }
                    }
                    // bottom 
                    for(int k = i + 1; k < n; k++) {
                        if(arr[k][j] == '+') {
                            bottom++;
                        }
                        else {
                            break;
                        }
                    }
                    // left 
                    for(int k = j - 1; k >= 0; k--) {
                        if(arr[i][k] == '+') {
                            left++;
                        }
                        else {
                            break;
                        }
                    }
                    // right 
                    for(int k = j + 1; k < m; k++) {
                        if(arr[i][k] == '+') {
                            right++;
                        }
                        else {
                            break;
                        }
                    }

                    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 08:25:11
Judged At
2024-12-09 08:25:11
Judged By
Score
60
Total Time
≥2099ms
Peak Memory
≥4.574 MiB