Submission #641942

# Submission time Handle Problem Language Result Execution time Memory
641942 2022-09-17T23:41:43 Z HibaKhalil Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
33 ms 5108 KB
#include<bits/stdc++.h>
 
using namespace std;
 
int main (){
    int r,c,d,k;
    cin>>r>>c>>d>>k;
    char grid[r+1][c+1];
    for(int i=1;i<=r;i++) 
    {
        for(int j=1;j<=c;j++)
        {
            cin>>grid[i][j];
        }
    }
    int sprinkles[r+1][c+1];
 
    for (int i=0;i<=r;i++)
    {
        for (int j=0;j<=c;j++)
        {
            if(i==0 || j==0)
            {
                sprinkles[i][j]=0;
                continue;
            }
            sprinkles[i][j]=sprinkles[i-1][j];
            if(grid[i][j]=='S'){
                sprinkles[i][j]++;
            }
        }
    }
    
    for (int i=1;i<=r;i++)
    {
        for (int j=1;j<=c;j++)
        {
            sprinkles[i][j]+=sprinkles[i][j-1];
        }
    }
    int res = 0;
 
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            if(grid[i][j]=='M'){
                int i1 , j1 , i2 , j2;
                if(i-d>0) i1=i-d;
                else i1=1;
                if(i+d<=r) i2=i+d;
                else i2=r;
                if(j-d>0) j1=j-d;
                else j1=1;
                if(j+d<=c) j2=j+d;
                else j2=c;
                int tmp=sprinkles[i1-1][j2]+sprinkles[i2][j1-1]-sprinkles[i1-1][j1-1];
              //  cout<<tmp<<" "<<sprinkles[i2][j2]<<endl;
                if(sprinkles[i2][j2]-tmp>=k) {
                    res++;
                }
            }
        }
    }
 
    cout<<res<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1252 KB Output is correct
2 Correct 12 ms 1456 KB Output is correct
3 Correct 16 ms 1756 KB Output is correct
4 Correct 13 ms 1464 KB Output is correct
5 Correct 13 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 5108 KB Output is correct
2 Correct 32 ms 5108 KB Output is correct
3 Correct 32 ms 5100 KB Output is correct
4 Correct 33 ms 5080 KB Output is correct
5 Correct 31 ms 5108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 11 ms 1252 KB Output is correct
17 Correct 12 ms 1456 KB Output is correct
18 Correct 16 ms 1756 KB Output is correct
19 Correct 13 ms 1464 KB Output is correct
20 Correct 13 ms 1492 KB Output is correct
21 Correct 33 ms 5108 KB Output is correct
22 Correct 32 ms 5108 KB Output is correct
23 Correct 32 ms 5100 KB Output is correct
24 Correct 33 ms 5080 KB Output is correct
25 Correct 31 ms 5108 KB Output is correct
26 Correct 29 ms 3148 KB Output is correct
27 Correct 30 ms 3148 KB Output is correct
28 Correct 30 ms 3180 KB Output is correct
29 Correct 33 ms 3188 KB Output is correct
30 Correct 30 ms 3148 KB Output is correct