Submission #1063810

# Submission time Handle Problem Language Result Execution time Memory
1063810 2024-08-18T03:35:50 Z Luvidi Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
13 ms 8284 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

void solve() {
    int n,m,d,k;
    cin>>n>>m>>d>>k;
    int a[n+1][m+1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char c;
            cin>>c;
            if(c=='.')a[i][j]=0;
            else if(c=='M')a[i][j]=1;
            else a[i][j]=2;
        }
    }
    int pre[n+1][m+1];
    memset(pre,0,sizeof(pre));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]==2){
                pre[max(1,i-d)][max(1,j-d)]++;
                if(i+d+1<=n)pre[i+d+1][max(1,j-d)]--;
                if(j+d+1<=m)pre[max(1,i-d)][j+d+1]--;
                if(i+d+1<=n&&j+d+1<=m)pre[i+d+1][j+d+1]++;
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            pre[i][j]+=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];
            ans+=a[i][j]==1&&pre[i][j]>=k;
        }
    }
    cout<<ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 388 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1880 KB Output is correct
2 Correct 3 ms 1884 KB Output is correct
3 Correct 4 ms 2652 KB Output is correct
4 Correct 3 ms 2232 KB Output is correct
5 Correct 3 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 8028 KB Output is correct
2 Correct 10 ms 8200 KB Output is correct
3 Correct 11 ms 8284 KB Output is correct
4 Correct 12 ms 8028 KB Output is correct
5 Correct 13 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 388 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 1880 KB Output is correct
17 Correct 3 ms 1884 KB Output is correct
18 Correct 4 ms 2652 KB Output is correct
19 Correct 3 ms 2232 KB Output is correct
20 Correct 3 ms 2392 KB Output is correct
21 Correct 12 ms 8028 KB Output is correct
22 Correct 10 ms 8200 KB Output is correct
23 Correct 11 ms 8284 KB Output is correct
24 Correct 12 ms 8028 KB Output is correct
25 Correct 13 ms 8028 KB Output is correct
26 Correct 12 ms 4828 KB Output is correct
27 Correct 10 ms 4700 KB Output is correct
28 Correct 10 ms 4700 KB Output is correct
29 Correct 10 ms 4700 KB Output is correct
30 Correct 11 ms 4700 KB Output is correct