#define REP(i, n) for(int i = 0; i < n; i ++)
#define REPL(i,m, n) for(int i = m; i < n; i ++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define SORT(arr) sort(arr.begin(), arr.end())
#define LSOne(S) ((S)&-(S))
#define M_PI 3.1415926535897932384
#define INF 999999999
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int r,c,d,k;cin>>r>>c>>d>>k;
vector<string> arr(r);
REP(i, r) {
cin>>arr[i];
}
vector<vii> actions(r);
REP(i, r) {
REP(j, c) {
if (arr[i][j] == 'S') {
int si = max(0, i-d);
int ei = i+d+1;
int sj = max(0, j-d);
int ej = j+d+1;
actions[si].push_back({sj, 1});
if (ej < c) {
actions[si].push_back({ej, -1});
}
if (ei < r) {
actions[ei].push_back({sj, -1});
if (ej < c) {
actions[ei].push_back({ej, 1});
}
}
}
}
}
vvi amt(r, vi(c));
vi diffarr(c, 0);
REP(i, r) {
for (auto [idx, co]: actions[i]) {
diffarr[idx] += co;
}
int cur = 0;
REP(j, c) {
cur += diffarr[j];
amt[i][j] = cur;
}
}
int tot = 0;
REP(i, r) {
REP(j, c) {
if (arr[i][j] == 'M' && amt[i][j] >= k) {
tot++;
}
}
}cout<<tot;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
444 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1448 KB |
Output is correct |
2 |
Correct |
2 ms |
1464 KB |
Output is correct |
3 |
Correct |
3 ms |
1760 KB |
Output is correct |
4 |
Correct |
3 ms |
1444 KB |
Output is correct |
5 |
Correct |
2 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6360 KB |
Output is correct |
2 |
Correct |
5 ms |
5464 KB |
Output is correct |
3 |
Correct |
6 ms |
5588 KB |
Output is correct |
4 |
Correct |
13 ms |
8484 KB |
Output is correct |
5 |
Correct |
9 ms |
6032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
444 KB |
Output is correct |
9 |
Correct |
1 ms |
304 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
312 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
312 KB |
Output is correct |
14 |
Correct |
0 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
316 KB |
Output is correct |
16 |
Correct |
1 ms |
1448 KB |
Output is correct |
17 |
Correct |
2 ms |
1464 KB |
Output is correct |
18 |
Correct |
3 ms |
1760 KB |
Output is correct |
19 |
Correct |
3 ms |
1444 KB |
Output is correct |
20 |
Correct |
2 ms |
1528 KB |
Output is correct |
21 |
Correct |
8 ms |
6360 KB |
Output is correct |
22 |
Correct |
5 ms |
5464 KB |
Output is correct |
23 |
Correct |
6 ms |
5588 KB |
Output is correct |
24 |
Correct |
13 ms |
8484 KB |
Output is correct |
25 |
Correct |
9 ms |
6032 KB |
Output is correct |
26 |
Correct |
11 ms |
7100 KB |
Output is correct |
27 |
Correct |
5 ms |
3788 KB |
Output is correct |
28 |
Correct |
10 ms |
5564 KB |
Output is correct |
29 |
Correct |
6 ms |
4332 KB |
Output is correct |
30 |
Correct |
9 ms |
5820 KB |
Output is correct |