#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll r,c,d,k,to=0;
vector<vector<ll>> mp;
vector<string> tmp;
void set(int y,int x,int d)
{
int tly = max(y-d,1),tlx = max(x-d,1);
int bry = min(y+d,(int)r),brx = min(x+d,(int)c);
//cout<<tly<<" "<<tlx<<" "<<bry<<" "<<brx<<"\n";
mp[tly][tlx] ++;
mp[tly][brx+1] --;
mp[bry+1][tlx] --;
mp[bry+1][brx+1] ++;
}
int main()
{
cin>>r>>c>>d>>k;
for (int i=0;i<r+2;i++)
{
mp.push_back(vector<ll>());
for (int j=0;j<c+2;j++)
{
mp[i].push_back(0);
}
}
string trsh = "";
for (int i=0;i<c;i++)
{
trsh+=" ";
}
tmp.push_back(trsh);
for (int i=0;i<r;i++)
{
string tp;cin>>tp;
tp=" "+tp;tp+=" ";
tmp.push_back(tp);
}
tmp.push_back(trsh);
for (int i=1;i<=r;i++)
{
for (int j=1;j<=c;j++)
{
if (tmp[i][j]=='S') {set(i,j,d);}
}
}
for (int i=1;i<=r;i++)
{
for (int j=1;j<=c;j++)
{
mp[i][j] += mp[i-1][j] + mp[i][j-1] - mp[i-1][j-1];
if (tmp[i][j]=='M'&&mp[i][j]>=k) {to++;}
}
}
cout<<to<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
392 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
2424 KB |
Output is correct |
2 |
Correct |
19 ms |
2680 KB |
Output is correct |
3 |
Correct |
23 ms |
2888 KB |
Output is correct |
4 |
Correct |
19 ms |
2424 KB |
Output is correct |
5 |
Correct |
21 ms |
2808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
15308 KB |
Output is correct |
2 |
Correct |
67 ms |
15212 KB |
Output is correct |
3 |
Correct |
69 ms |
15308 KB |
Output is correct |
4 |
Correct |
72 ms |
15180 KB |
Output is correct |
5 |
Correct |
71 ms |
15180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
392 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
380 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
504 KB |
Output is correct |
14 |
Correct |
2 ms |
380 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
18 ms |
2424 KB |
Output is correct |
17 |
Correct |
19 ms |
2680 KB |
Output is correct |
18 |
Correct |
23 ms |
2888 KB |
Output is correct |
19 |
Correct |
19 ms |
2424 KB |
Output is correct |
20 |
Correct |
21 ms |
2808 KB |
Output is correct |
21 |
Correct |
72 ms |
15308 KB |
Output is correct |
22 |
Correct |
67 ms |
15212 KB |
Output is correct |
23 |
Correct |
69 ms |
15308 KB |
Output is correct |
24 |
Correct |
72 ms |
15180 KB |
Output is correct |
25 |
Correct |
71 ms |
15180 KB |
Output is correct |
26 |
Correct |
63 ms |
9392 KB |
Output is correct |
27 |
Correct |
46 ms |
6332 KB |
Output is correct |
28 |
Correct |
44 ms |
5496 KB |
Output is correct |
29 |
Correct |
43 ms |
5496 KB |
Output is correct |
30 |
Correct |
61 ms |
10576 KB |
Output is correct |