#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int r, c, d, k;
cin >> r >> c >> d >> k;
int ans = 0;
int prefix[r + 2][c + 2];
vector<pair<int, int>>v;
memset(prefix, 0, sizeof(prefix));
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
char x; cin >> x;
prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + (x == 'S');
if(x == 'M') v.emplace_back(i, j);
}
}
for(auto &[x, y]: v){
int TLX = max(1, (x - d));
int TLY = max(1, (y - d));
int BRX = min(r, (x + d));
int BRY = min(c, (y + d));
int tmp = prefix[BRX][BRY] - prefix[BRX][TLY - 1] - prefix[TLX - 1][BRY] + prefix[TLX - 1][TLY - 1];
ans += (tmp >= k);
}
cout << ans << "\n";
return 0;
}
Compilation message
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:24:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
24 | for(auto &[x, y]: v){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
972 KB |
Output is correct |
2 |
Correct |
3 ms |
1100 KB |
Output is correct |
3 |
Correct |
7 ms |
1292 KB |
Output is correct |
4 |
Correct |
3 ms |
1100 KB |
Output is correct |
5 |
Correct |
4 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
8340 KB |
Output is correct |
2 |
Correct |
17 ms |
10392 KB |
Output is correct |
3 |
Correct |
15 ms |
10400 KB |
Output is correct |
4 |
Correct |
13 ms |
8264 KB |
Output is correct |
5 |
Correct |
17 ms |
10436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
972 KB |
Output is correct |
17 |
Correct |
3 ms |
1100 KB |
Output is correct |
18 |
Correct |
7 ms |
1292 KB |
Output is correct |
19 |
Correct |
3 ms |
1100 KB |
Output is correct |
20 |
Correct |
4 ms |
1100 KB |
Output is correct |
21 |
Correct |
14 ms |
8340 KB |
Output is correct |
22 |
Correct |
17 ms |
10392 KB |
Output is correct |
23 |
Correct |
15 ms |
10400 KB |
Output is correct |
24 |
Correct |
13 ms |
8264 KB |
Output is correct |
25 |
Correct |
17 ms |
10436 KB |
Output is correct |
26 |
Correct |
11 ms |
3532 KB |
Output is correct |
27 |
Correct |
12 ms |
4424 KB |
Output is correct |
28 |
Correct |
11 ms |
3508 KB |
Output is correct |
29 |
Correct |
11 ms |
3404 KB |
Output is correct |
30 |
Correct |
14 ms |
4428 KB |
Output is correct |