/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 8ms 796.0 KiB
#3 Accepted 13ms 540.0 KiB
#4 Accepted 15ms 540.0 KiB
#5 Accepted 11ms 908.0 KiB
#6 Accepted 15ms 796.0 KiB
#7 Accepted 99ms 752.0 KiB
#8 Accepted 39ms 756.0 KiB
#9 Accepted 27ms 3.113 MiB
#10 Accepted 26ms 1.027 MiB
#11 Accepted 222ms 948.0 KiB
#12 Accepted 807ms 2.82 MiB
#13 Accepted 17ms 3.098 MiB
#14 Accepted 15ms 2.355 MiB
#15 Accepted 18ms 4.352 MiB
#16 Accepted 16ms 4.195 MiB
#17 Accepted 16ms 2.344 MiB
#18 Accepted 836ms 3.637 MiB
#19 Accepted 20ms 3.52 MiB
#20 Accepted 695ms 3.891 MiB
#21 Time Exceeded ≥2096ms ≥4.188 MiB
#22 Accepted 180ms 4.383 MiB
#23 Accepted 195ms 4.27 MiB
#24 Accepted 199ms 4.375 MiB
#25 Accepted 99ms 4.27 MiB
#26 Accepted 994ms 4.383 MiB
#27 Accepted 186ms 4.348 MiB
#28 Accepted 143ms 4.383 MiB
#29 Accepted 1883ms 4.383 MiB
#30 Time Exceeded ≥2097ms ≥4.258 MiB

Code

#include <bits/stdc++.h>
#define nl '\n'
#define ll long long int
#define all(v) v.begin(),v.end()
#define print(v) for(auto data : v) cout << data << " "; cout << nl
using namespace std;
const int N = 2e3 + 5;
char mat[N][N];
int n, m;
bool is_valid_i(int i)
{
    return !(i >= n || i < 0);
}
bool is_valid_j(int j)
{
    return !(j >= m || j < 0);
}
void solve()
{
    cin >> n >> m;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> mat[i][j]; mat[i][j] == '+'? ans = 1 : ans;
        }
    }
    if(ans ==  0)
    {
        cout << 0 << nl; return;
    }

    int mx_cnt = min(n,m) + min(n,m) - 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(mat[i][j] == '+')
            {
                int e = i+1, w = i-1, n = j+1, s = j-1;
                int cnt = 0;
                while (is_valid_i(e) && is_valid_i(w) && is_valid_j(n) && is_valid_j(s) &&
                mat[e][j] == '+' && mat[w][j] == '+' && mat[i][n] == '+' && mat[i][s] == '+')
                {
                    cnt += 4; e++, w--, n++, s--;
                }
                ans = max(ans, cnt + 1);
                if(ans == mx_cnt)
                {
                    cout << ans << nl; return;
                }
            }
        }
    }
    cout << ans << nl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int t; cin >> t; 
    while (t--) solve();

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1143 Plus of Pluses
Contest
LU IUJPC : Sylhet Division 2024 Replay Contest
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-10 11:45:06
Judged At
2024-12-10 11:45:06
Judged By
Score
92
Total Time
≥2097ms
Peak Memory
≥4.383 MiB