/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 11ms 564.0 KiB
#3 Accepted 31ms 684.0 KiB
#4 Accepted 39ms 796.0 KiB
#5 Accepted 25ms 572.0 KiB
#6 Accepted 37ms 584.0 KiB
#7 Accepted 183ms 564.0 KiB
#8 Accepted 37ms 348.0 KiB
#9 Accepted 37ms 540.0 KiB
#10 Accepted 38ms 656.0 KiB
#11 Accepted 508ms 656.0 KiB
#12 Accepted 1731ms 1.5 MiB
#13 Accepted 333ms 1.496 MiB
#14 Accepted 14ms 1.32 MiB
#15 Accepted 560ms 1.496 MiB
#16 Accepted 16ms 1.277 MiB
#17 Accepted 21ms 1.5 MiB
#18 Time Exceeded ≥2047ms ≥1.32 MiB
#19 Accepted 35ms 1.496 MiB
#20 Time Exceeded ≥2052ms ≥1.5 MiB

Code

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

#define endl '\n'

int main()
{
   ios :: sync_with_stdio(false);cin.tie(0);cout.tie(0);

    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:41:22
Judged At
2024-12-09 08:41:22
Judged By
Score
52
Total Time
≥2052ms
Peak Memory
≥1.5 MiB