/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 772.0 KiB
#2 Accepted 9ms 772.0 KiB
#3 Accepted 16ms 796.0 KiB
#4 Accepted 16ms 848.0 KiB
#5 Accepted 14ms 1.004 MiB
#6 Accepted 17ms 952.0 KiB
#7 Accepted 91ms 980.0 KiB
#8 Accepted 36ms 892.0 KiB
#9 Accepted 39ms 2.414 MiB
#10 Accepted 38ms 2.406 MiB
#11 Accepted 189ms 4.121 MiB
#12 Accepted 604ms 19.625 MiB
#13 Accepted 23ms 11.469 MiB
#14 Accepted 14ms 1.277 MiB
#15 Accepted 23ms 11.559 MiB
#16 Accepted 14ms 1.543 MiB
#17 Accepted 14ms 1.527 MiB
#18 Accepted 609ms 19.559 MiB
#19 Accepted 23ms 7.449 MiB
#20 Accepted 523ms 19.43 MiB
#21 Time Exceeded ≥2095ms ≥70.512 MiB
#22 Accepted 204ms 70.41 MiB
#23 Accepted 231ms 70.496 MiB
#24 Accepted 212ms 70.473 MiB
#25 Accepted 137ms 38.496 MiB
#26 Accepted 832ms 70.551 MiB
#27 Accepted 218ms 70.598 MiB
#28 Accepted 180ms 70.465 MiB
#29 Accepted 1393ms 70.602 MiB
#30 Accepted 1842ms 70.73 MiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
#define pb push_back
#define MOD 1000000007
#define vll vector<ll>
#define endl "\n" 
#define all(v) v.begin(), v.end()
#define mem(a,b) memset(a, b, sizeof(a))
#define co(n) cout << n << endl
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define fr(x, n) for (int i = x; i < n; ++i)
#define fraction(x) cout << fixed << setprecision(x)
#define Baba_Yaga ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
const double eps = 1e-9;
const int N = 2e5+123;
 
ll gcd(ll a,ll b) { return __gcd(a,b); }
ll lcm(ll a,ll b) { return (a*b)/__gcd(a,b); }
 
int dx[] = {0, 0, +1, -1, +1, +1, -1, -1};
int dy[] = {+1, -1, 0, 0, +1, -1, +1, -1};
 

void solve()
{
    ll n, m; cin >> n >> m;
    char arr[n][m];
    ll one  = 0;
    vector<pair<ll,ll>> vp;
    

    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m; j++)
        {
            cin >> arr[i][j];
            if(arr[i][j] == '+')
            {
                one = 1;
                vp.pb({i, j});
            }
        }
    }
    if(one == 0)
    {
        cout << 0 << endl;
        return;
    }
    
    
    ll maxi = 0;
    for(int c=0; c<vp.size(); c++)
    {
        ll i = vp[c].first, j = vp[c].second;
           
        ll ct = 0;
        for(int k=1; k <= min(n/2, m/2) ; k++)
        {
            if(i+k >= n || j+k >= m || i-k < 0 || j-k < 0 || arr[i+k][j] != '+' || arr[i-k][j] != '+'|| arr[i][j+k] != '+' || arr[i][j-k] != '+')
            {
                break;
            }
            else ct++;
        }
        maxi = max(maxi, ct);      
    }
     
     cout << maxi * 4 + 1 << endl;

}

int main()
{
    Baba_Yaga;
    ll tc = 1; cin >> tc;
    for(int i=1; i<=tc; i++)
    {
       // cout << "Case " << i << ": ";
        solve();
    }   
}

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:06:12
Judged At
2024-12-09 08:06:12
Judged By
Score
96
Total Time
≥2095ms
Peak Memory
≥70.73 MiB