/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 1.277 MiB
#2 Accepted 10ms 1.277 MiB
#3 Accepted 11ms 1.324 MiB
#4 Accepted 12ms 1.277 MiB
#5 Accepted 12ms 1.5 MiB
#6 Accepted 11ms 1.277 MiB
#7 Accepted 49ms 1.324 MiB
#8 Accepted 36ms 1.324 MiB
#9 Accepted 42ms 1.422 MiB
#10 Accepted 35ms 1.277 MiB
#11 Accepted 102ms 1.527 MiB
#12 Accepted 366ms 2.281 MiB
#13 Accepted 18ms 2.277 MiB
#14 Accepted 15ms 2.277 MiB
#15 Accepted 19ms 2.316 MiB
#16 Accepted 16ms 2.07 MiB
#17 Accepted 18ms 2.289 MiB
#18 Accepted 334ms 2.32 MiB
#19 Accepted 25ms 2.523 MiB
#20 Accepted 280ms 2.289 MiB
#21 Time Exceeded ≥2028ms ≥5.027 MiB
#22 Accepted 302ms 5.164 MiB
#23 Accepted 339ms 5.172 MiB
#24 Accepted 319ms 5.168 MiB
#25 Accepted 189ms 5.172 MiB
#26 Accepted 1428ms 5.164 MiB
#27 Accepted 296ms 5.164 MiB
#28 Accepted 144ms 5.168 MiB
#29 Accepted 1145ms 5.277 MiB
#30 Accepted 1513ms 5.277 MiB

Code

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

#define ll long long
#define ld long double
#define MOD 1000000007
#define pie 2 * (acos(0.0))
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define pb push_back
#define nl '\n'
#define lcm(a, b) (a * b) / (__gcd<ll>(a, b))
#define print(v)          \
    for (auto e : v)      \
        cout << e << " "; \
    cout << endl;
#define printp(v)    \
    for (auto e : v) \
        cout << e.first << " " << e.second << endl;
#define srt(v) sort(v.begin(), v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define F first
#define S second
#define setbit(x) __builtin_popcount(x)
#define sz(x) (int)(x).size()
#define vi vector<int>
#define pi pair<int, int>
#define even(n) if (n % 2 == 0)
#define odd(n) if (n % 2 == 1)
#define sp << " " <<

#define alliswell                \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);

const int mx = 1e5+100;
vector<int>ar(mx, 5);
vector<int> pfs (mx, 5);


void solve()
{
    int n , m;
    cin >> n >> m;
    int mx = 0;
    int mn = min(n, m);
    int bk = (mn-1)*2+1;

    //cout << bk << endl;

    char s[n+10][m+10];
    int cnt = 0;

    for(int i = 0; i < n; i++){
       for(int j = 0; j < m ; j++){
            cin >> s[i][j];
            if(  s[i][j] == '+')  {
                mx = 1;
                cnt++;
            }

       }
       //getchar();
    }

    bool f = 0;

    if (cnt >= 1 && cnt < 5){
        cout << 1 << endl;
        f = 1;
        return;
    }
    if (cnt == 0){
        cout << 0 << endl;
        f = 1;
        return;
    }

    
    for(int i = 1; i < n-1; i++){
        if(mx == bk  || f == 1){
                f = 1;
                break;
            }
        for(int j = 1; j < m-1 ; j++){
            if(mx == bk  || f == 1){
                f = 1;
                break;
            }
            if(  s[i][j] == '+'){
                int ans = 1;
                mx = max(mx, ans);

                int k = 1;
                while(i+k < n && j + k < m && i - k >= 0 && j - k >= 0){
                    if(mx == bk || f == 1){
                         f = 1;
                       break;
                     }
                    if(s[i-k][j] == '+' && s[i+k][j] == '+' && s[i][j-k] == '+' && s[i][j+k] == '+' ){
                        ans+=4;
                        mx = max(mx, ans);
                        k++;
                    }
                    else {
                        break;
                    }

                    if(i+k >= n && j + k >= m){
                        f = 1;
                        break;
                    }
                    // if(i-k < 0 && j-k < 0){
                    //     f = 1;
                    //     break;
                    // }

                }
            }
        }
    }

    cout << mx << endl;
   // cout << "hey";
    
   
}
int main()
{
    alliswell

    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
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 08:54:01
Judged At
2024-12-09 08:54:01
Judged By
Score
96
Total Time
≥2028ms
Peak Memory
≥5.277 MiB