#include <iostream>
#include <iomanip>
#include <array>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <bitset>
#include <climits>
#include <valarray>
#include <list>
#include <functional>
#include <unordered_map>
#define int long long int
#define inf 100000000000
#define endl '\n'
#define mod 998244353
using namespace std;
signed main(){
int r,c,d,k; cin >> r >> c >> d >> k;
char a[r+1][c+1];
int pre[r+1][c+1];
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
cin >> a[i][j];
pre[i][j] = 0;
}
}
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
pre[i][j] = pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+(a[i][j] == 'S');
}
}
int cnt = 0;
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
if (a[i][j] != 'M') continue;
int u = max(i-d,1LL);
int v = max(j-d, 1LL);
int w = min(i+d, r);
int x = min(j+d, c);
int cur = pre[w][x]-pre[u-1][w]-pre[w][v-1]+pre[u-1][v-1];
if (cur >= k) cnt++;
}
}
cout << cnt << endl;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
2036 KB |
Output is correct |
2 |
Incorrect |
13 ms |
2096 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
9084 KB |
Output is correct |
2 |
Correct |
34 ms |
9044 KB |
Output is correct |
3 |
Correct |
34 ms |
9044 KB |
Output is correct |
4 |
Correct |
34 ms |
9044 KB |
Output is correct |
5 |
Correct |
35 ms |
9044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |