#include<bits/stdc++.h>
using namespace std;
int main (){
int r,c,d,k;
cin>>r>>c>>d>>k;
char grid[r][c];
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
cin>>grid[i][j];
}
}
int sprinkles[r][c];
for (int i=0;i<r;i++)
{
for (int j=0;j<c;j++)
{
sprinkles[i][j]=0;
if(i>0)sprinkles[i][j]+=sprinkles[i-1][j];
if(j>0)sprinkles[i][j]+=sprinkles[i][j-1];
if(i>0 && j>0) sprinkles[i][j]-=sprinkles[i-1][j-1];
if(grid[i][j]=='S'){
sprinkles[i][j]++;
}
}
}
int res = 0;
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
if(grid[i][j]=='M'){
int i1 , j1 , i2 , j2;
if(i-d>0) i1=i-d;
else i1=0;
if(i+d<r) i2=i+d;
else i2=r-1;
if(j-d>0) j1=j-d;
else j1=0;
if(j+d<c) j2=j+d;
else j2=c-1;
if(sprinkles[i2][j2]-sprinkles[i1][j1]>=k)
res++;
}
}
}
cout<<res<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
3176 KB |
Output is correct |
2 |
Incorrect |
30 ms |
3120 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |