#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
//#define int ll
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 998244353;
int n, m, d, k;
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>n>>m>>d>>k;
int t[n+2][m+2];
bool ms[n+2][m+2];
for(int i=1; i<=n; i++) for(int j=0; j<=m; j++) ms[i][j]=0;
for(int i=0; i<=n; i++) for(int j=0; j<=m; j++) t[i][j]=0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
char c;
cin>>c;
if(c=='M') ms[i][j]=1;
else if(c=='S'){
t[max(i-d, 1)][max(j-d, 1)]++;
t[min(i+d+1, n+1)][max(j-d, 1)]--;
t[max(i-d, 1)][min(j+d+1, m+1)]--;
t[min(i+d+1, n+1)][min(j+d+1, m+1)]++;
}
}
}
int ans=0;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
t[i][j]+=t[i-1][j]+t[i][j-1]-t[i-1][j-1];
//cout<<t[i][j]<<" ";
if(ms[i][j] && t[i][j]>=k) ans++;
}
//cout<<endl;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1528 KB |
Output is correct |
2 |
Correct |
8 ms |
1528 KB |
Output is correct |
3 |
Correct |
9 ms |
1784 KB |
Output is correct |
4 |
Correct |
8 ms |
1528 KB |
Output is correct |
5 |
Correct |
8 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
7160 KB |
Output is correct |
2 |
Correct |
20 ms |
6648 KB |
Output is correct |
3 |
Correct |
21 ms |
6328 KB |
Output is correct |
4 |
Correct |
25 ms |
7212 KB |
Output is correct |
5 |
Correct |
22 ms |
7032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
7 ms |
1528 KB |
Output is correct |
17 |
Correct |
8 ms |
1528 KB |
Output is correct |
18 |
Correct |
9 ms |
1784 KB |
Output is correct |
19 |
Correct |
8 ms |
1528 KB |
Output is correct |
20 |
Correct |
8 ms |
1656 KB |
Output is correct |
21 |
Correct |
23 ms |
7160 KB |
Output is correct |
22 |
Correct |
20 ms |
6648 KB |
Output is correct |
23 |
Correct |
21 ms |
6328 KB |
Output is correct |
24 |
Correct |
25 ms |
7212 KB |
Output is correct |
25 |
Correct |
22 ms |
7032 KB |
Output is correct |
26 |
Correct |
19 ms |
3420 KB |
Output is correct |
27 |
Correct |
18 ms |
3320 KB |
Output is correct |
28 |
Correct |
20 ms |
3256 KB |
Output is correct |
29 |
Correct |
19 ms |
3320 KB |
Output is correct |
30 |
Correct |
19 ms |
3324 KB |
Output is correct |