#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
int main(void)
{
int r, c, d, k; cin >> r >> c >> d >> k;
vector<pair<int, int>> v;
vector<pair<int, int>> s;
char x;
int a[r + 2][c + 2] = {};
for(int i = 1; i <= r; i++)
{
for(int j = 1; j <= c; j++)
{
cin >> x;
if(x == 'M') v.push_back(make_pair(i, j));
if(x == 'S')
{
for(int ix = max(1, i - d); ix <= min(r, i + d); ix++)
{
a[ix][max(1, j - d)]++;
a[ix][min(c + 1, j + d + 1)]--;
}
}
}
}
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)
a[i][j] += a[i][j - 1];
// for(int i = 1; i <= r + 1; i++) { for(int j = 1; j <= c + 1; j++) cout << a[i][j] << " "; cout << endl; }
int ans = 0;
for(auto u : v) if(a[u.fi][u.se] >= 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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
348 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 |
6 ms |
632 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1144 KB |
Output is correct |
2 |
Correct |
24 ms |
1144 KB |
Output is correct |
3 |
Correct |
29 ms |
1372 KB |
Output is correct |
4 |
Correct |
25 ms |
1172 KB |
Output is correct |
5 |
Correct |
25 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
8424 KB |
Output is correct |
2 |
Correct |
66 ms |
10468 KB |
Output is correct |
3 |
Correct |
66 ms |
10396 KB |
Output is correct |
4 |
Correct |
65 ms |
8424 KB |
Output is correct |
5 |
Correct |
67 ms |
10424 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 |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
348 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 |
6 ms |
632 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
504 KB |
Output is correct |
16 |
Correct |
23 ms |
1144 KB |
Output is correct |
17 |
Correct |
24 ms |
1144 KB |
Output is correct |
18 |
Correct |
29 ms |
1372 KB |
Output is correct |
19 |
Correct |
25 ms |
1172 KB |
Output is correct |
20 |
Correct |
25 ms |
1144 KB |
Output is correct |
21 |
Correct |
64 ms |
8424 KB |
Output is correct |
22 |
Correct |
66 ms |
10468 KB |
Output is correct |
23 |
Correct |
66 ms |
10396 KB |
Output is correct |
24 |
Correct |
65 ms |
8424 KB |
Output is correct |
25 |
Correct |
67 ms |
10424 KB |
Output is correct |
26 |
Execution timed out |
2045 ms |
3264 KB |
Time limit exceeded |
27 |
Halted |
0 ms |
0 KB |
- |