/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 11ms 1.027 MiB
#3 Accepted 30ms 1012.0 KiB
#4 Accepted 34ms 2.848 MiB
#5 Accepted 25ms 2.895 MiB
#6 Accepted 34ms 2.527 MiB
#7 Accepted 162ms 2.805 MiB
#8 Accepted 39ms 2.777 MiB
#9 Accepted 41ms 10.777 MiB
#10 Accepted 39ms 4.777 MiB
#11 Accepted 419ms 4.777 MiB
#12 Accepted 1316ms 20.883 MiB
#13 Accepted 283ms 20.859 MiB
#14 Accepted 20ms 20.723 MiB
#15 Accepted 405ms 20.891 MiB
#16 Accepted 21ms 20.586 MiB
#17 Accepted 22ms 18.855 MiB
#18 Accepted 1303ms 19.051 MiB
#19 Accepted 25ms 20.605 MiB
#20 Accepted 1142ms 20.832 MiB
#21 Time Exceeded ≥2074ms ≥39.199 MiB
#22 Time Exceeded ≥2093ms ≥38.727 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl << "\n"
#define yes << "YES\n"
#define no << "NO\n"
#define sp " "
ll n, k;
const int N = 20000, K = 20000;
char a[N][K];
ll clk(ll x, ll y)
{
    ll val, mn = 0;
    ll left = 0, right = 0, up = 0, down = 0;

    for (int i = y - 1; i >= 0; i--)
    {

        if (a[x][i] == '+')
        {
            left++;
        }
        else
        {

            break;
        }
    }
    for (int i = y + 1; i < k; i++)
    {

        if (a[x][i] == '+')
        {
            right++;
        }
        else
        {
            break;
        }
    }
    for (int i = x - 1; i >= 0; i--)
    {

        if (a[i][y] == '+')
        {
            up++;
        }
        else
        {

            break;
        }
    }

    for (int i = x + 1; i < n; i++)
    {

        if (a[i][y] == '+')
        {
            down++;
        }
        else
        {

            break;
        }
    }

    val = min({left, right, up, down});

    return (4 * val) + 1;
    // else return 0;
}
void solve()
{

    cin >> n >> k;
    int c = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < k; j++)
        {
            cin >> a[i][j];
            if (a[i][j] == '+')
                c++;
        }
    }

    ll mx = 0, cnt = 0;
    // clk(2,3);
    int i = 0, j = 0;
    while (i < n)

    {

        if (a[i][j] == '+')
        {
            mx = max(mx, clk(i, j));
        }
        if (j == k-1)
        {
            i++, j = 0;
        }
        else
            j++;
    }

    cout << mx nl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll t;
    cin >> t;
    for (ll i = 0; i < t; i++)
        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 09:09:41
Judged At
2024-12-09 09:09:41
Judged By
Score
60
Total Time
≥2093ms
Peak Memory
≥39.199 MiB