Submission #649588

# Submission time Handle Problem Language Result Execution time Memory
649588 2022-10-10T21:47:23 Z ShahdMohamed Collecting Mushrooms (NOI18_collectmushrooms) C++17
79 / 100
2000 ms 6380 KB
///LW M4 ACC HAZ3L GAMED
///YARAB WALA...I MEAN YARAB ACC
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
const ll mod = (ll) 1e9 + 7;
const ll even = (ll) 1e9 + 2;
const ll oo= (ll) 1e16;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<vector<char>>v(n,vector<char>(m));
    for (ll i=0; i<n; i++)
    {
        for (ll j=0; j<m; j++)
            cin>>v[i][j];
    }
    if (n==1)
    {
        vector<ll>frq(m+1);
        for (ll i=0; i<n; i++)
        {
            for (ll j=0; j<m; j++)
            {
                if (v[i][j]=='S')
                {
                    frq[max(0ll,j-x)]++;
                    frq[min(m,j+x+1)]--;
                }
            }
        }
        for (ll i=1; i<=m; i++)
            frq[i]+=frq[i-1];
        ll ans=0;
        for (ll i=0; i<n; i++)
        {
            for (ll j=0; j<m; j++)
            {
                if (v[i][j]=='M' and frq[j]>=y)ans++;
            }
        }
        cout<<ans<<endl;
    }
    else
    {
        vector<vector<ll>>frq(n,vector<ll>(m,0));
        for (ll i=0; i<n; i++)
        {
            for (ll j=0; j<m; j++)
            {
                if (v[i][j]=='S')
                {
                    for (ll k=max(0ll,i-x); k<=min(n-1,i+x); k++)
                    {
                        for (ll h=max(0ll,j-x); h<=min(m-1,j+x); h++)
                            frq[k][h]++;
                    }
                }
            }
        }
        ll ans=0;
        for (ll i=0; i<n; i++)
        {
            for (ll j=0; j<m; j++)
            {
                if (v[i][j]=='M' and frq[i][j]>=y)ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 27 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 27 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 75 ms 396 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2068 KB Output is correct
2 Correct 57 ms 2132 KB Output is correct
3 Correct 15 ms 2516 KB Output is correct
4 Correct 111 ms 2156 KB Output is correct
5 Correct 5 ms 2260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 4712 KB Output is correct
2 Correct 10 ms 4712 KB Output is correct
3 Correct 11 ms 4712 KB Output is correct
4 Correct 11 ms 4712 KB Output is correct
5 Correct 11 ms 4712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 27 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 75 ms 396 KB Output is correct
9 Correct 3 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 16 ms 2068 KB Output is correct
17 Correct 57 ms 2132 KB Output is correct
18 Correct 15 ms 2516 KB Output is correct
19 Correct 111 ms 2156 KB Output is correct
20 Correct 5 ms 2260 KB Output is correct
21 Correct 11 ms 4712 KB Output is correct
22 Correct 10 ms 4712 KB Output is correct
23 Correct 11 ms 4712 KB Output is correct
24 Correct 11 ms 4712 KB Output is correct
25 Correct 11 ms 4712 KB Output is correct
26 Execution timed out 2090 ms 6380 KB Time limit exceeded
27 Halted 0 ms 0 KB -