/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 7ms 988.0 KiB
#3 Accepted 10ms 1.039 MiB
#4 Accepted 15ms 2.949 MiB
#5 Accepted 10ms 980.0 KiB
#6 Accepted 11ms 2.996 MiB
#7 Accepted 58ms 3.027 MiB
#8 Accepted 23ms 2.613 MiB
#9 Accepted 37ms 6.816 MiB
#10 Accepted 23ms 3.277 MiB
#11 Accepted 123ms 3.277 MiB
#12 Accepted 422ms 9.43 MiB
#13 Accepted 20ms 11.109 MiB
#14 Accepted 17ms 10.949 MiB
#15 Accepted 20ms 9.371 MiB
#16 Accepted 17ms 11.105 MiB
#17 Accepted 18ms 11.598 MiB
#18 Accepted 594ms 9.453 MiB
#19 Accepted 20ms 10.812 MiB
#20 Accepted 354ms 11.051 MiB
#21 Time Exceeded ≥2098ms ≥19.676 MiB
#22 Accepted 129ms 19.359 MiB
#23 Accepted 138ms 20.77 MiB
#24 Accepted 136ms 20.852 MiB
#25 Accepted 88ms 21.16 MiB
#26 Accepted 567ms 19.504 MiB
#27 Accepted 153ms 19.703 MiB
#28 Accepted 117ms 19.281 MiB
#29 Accepted 959ms 20.773 MiB
#30 Accepted 1336ms 20.828 MiB

Code

#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define print(v) for(auto data : v) cout << data << " "; cout << endl;
using namespace std;
int n, m;
const int N = 1e4 + 5;
char mat[N][N];
void solve()
{
    cin >> n >> m; 
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> mat[i][j];
        }
    }
    int mx = 0;
    int mx_val = min(n, m) + min(n, m) - 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int temp = 1;
            int cnt = 0;
            if(mat[i][j] == '+')
            {
                while (i-1-cnt >= 1 && i-1-cnt <= n && 
                i+1+cnt >= 1 && i+1+cnt <= n &&
                j-1-cnt >= 1 && j-1-cnt <= m && 
                j+1+cnt >= 1 && j+1+cnt <= m
                && mat[i][j-1-cnt] == '+' && mat[i][j+1+cnt] == '+' &&
                mat[i-1-cnt][j] == '+' && mat[i+1+cnt][j] == '+')
                {
                    cnt++, temp += 4; 
                }
                mx = max(mx, temp);
                if(mx == mx_val) 
                {
                    cout << mx << endl; return;
                }
            }
        }
    }
    cout << mx << endl;
}
int main ()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int t; cin >> t;
    // int t = 1;
    while (t--) solve();
    
    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:15:21
Judged At
2024-12-09 07:15:21
Judged By
Score
96
Total Time
≥2098ms
Peak Memory
≥21.16 MiB