#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define ppair(x) "(" << x.first << ", " << x.second << ")"
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl
typedef long long ll;
int n, m, s, k;
vector<vector<char> > mat;
vector<vector<int> > sum;
void put(int i, int j, int val){
if (i >= n || j >= m) return;
sum[max(0, i)][max(0, j)] += val;
}
int main(){
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
cin >> n >> m >> s >> k;
mat.resize(n);
sum.resize(n);
for (int i = 0; i < n; i++){
mat[i].resize(m);
sum[i].resize(m);
for (int j = 0; j < m; j++){
cin >> mat[i][j];
sum[i][j] = 0;
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (mat[i][j] == 'S'){
put(i-s, j-s, 1);
put(i-s, j+s+1, -1);
put(i+s+1, j-s, -1);
put(i+s+1, j+s+1, 1);
}
}
}
for (int i = 1; i < n; i++){
for (int j = 0; j < m; j++){
sum[i][j] += sum[i-1][j];
}
}
for (int j = 1; j < m; j++){
for (int i = 0; i < n; i++){
sum[i][j] += sum[i][j-1];
}
}
ll ans = 0;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (mat[i][j] == 'M' && sum[i][j] >= k) ans++;
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 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 |
3 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
1272 KB |
Output is correct |
2 |
Correct |
26 ms |
1400 KB |
Output is correct |
3 |
Correct |
30 ms |
1528 KB |
Output is correct |
4 |
Correct |
26 ms |
1404 KB |
Output is correct |
5 |
Correct |
27 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
2808 KB |
Output is correct |
2 |
Correct |
60 ms |
2824 KB |
Output is correct |
3 |
Correct |
59 ms |
2816 KB |
Output is correct |
4 |
Correct |
64 ms |
2808 KB |
Output is correct |
5 |
Correct |
62 ms |
2856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 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 |
3 ms |
420 KB |
Output is correct |
14 |
Correct |
2 ms |
380 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
24 ms |
1272 KB |
Output is correct |
17 |
Correct |
26 ms |
1400 KB |
Output is correct |
18 |
Correct |
30 ms |
1528 KB |
Output is correct |
19 |
Correct |
26 ms |
1404 KB |
Output is correct |
20 |
Correct |
27 ms |
1400 KB |
Output is correct |
21 |
Correct |
61 ms |
2808 KB |
Output is correct |
22 |
Correct |
60 ms |
2824 KB |
Output is correct |
23 |
Correct |
59 ms |
2816 KB |
Output is correct |
24 |
Correct |
64 ms |
2808 KB |
Output is correct |
25 |
Correct |
62 ms |
2856 KB |
Output is correct |
26 |
Correct |
65 ms |
4496 KB |
Output is correct |
27 |
Correct |
61 ms |
2808 KB |
Output is correct |
28 |
Correct |
63 ms |
2724 KB |
Output is correct |
29 |
Correct |
60 ms |
2680 KB |
Output is correct |
30 |
Correct |
65 ms |
4040 KB |
Output is correct |