#include "bits/stdc++.h"
using namespace std;
#define int long long
#define fr first
#define sc second
#define eb emplace_back
#define nl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "LINE(" << __LINE__ << ") -> " <<"[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int R, C, D, K; cin >> R >> C >> D >> K;
int a[R + 2][C + 2] = {};
vector<pair<int, int>> mush;
for(int i = 1; i <= R; ++i) {
for(int j = 1; j <= C; ++j) {
char c; cin >> c;
if(c == '.') continue;
if(c == 'M') {
mush.eb(i, j);
continue;
}
int x, y;
x = max(0LL, i - D); y = max(0LL, j - D);
++a[x][y];
x = min(R + 1, i + D + 1); y = max(0LL, j - D);
--a[x][y];
x = max(0LL, i - D); y = min(C + 1, j + D + 1);
--a[x][y];
x = min(R + 1, i + D + 1); y = min(C + 1, j + D + 1);
++a[x][y];
}
}
for(int i = 0; i <= R + 1; ++i) {
for(int j = 0; j <= C + 1; ++j) {
a[i][j] = a[i][j] + (i ? a[i - 1][j] : 0) + (j ? a[i][j - 1] : 0) - (i && j ? a[i - 1][j - 1] : 0);
/* cout << a[i][j] << ' ' ; */
}
/* cout << nl; */
}
int res = 0;
for(auto [x, y] : mush) {
if(a[x][y] >= K) ++res;
}
cout << res << nl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
472 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
472 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
724 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2004 KB |
Output is correct |
2 |
Correct |
7 ms |
2132 KB |
Output is correct |
3 |
Correct |
8 ms |
2516 KB |
Output is correct |
4 |
Correct |
5 ms |
2160 KB |
Output is correct |
5 |
Correct |
6 ms |
2148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
16656 KB |
Output is correct |
2 |
Correct |
33 ms |
20800 KB |
Output is correct |
3 |
Correct |
31 ms |
20796 KB |
Output is correct |
4 |
Correct |
29 ms |
16796 KB |
Output is correct |
5 |
Correct |
34 ms |
20808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
472 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
580 KB |
Output is correct |
16 |
Correct |
5 ms |
2004 KB |
Output is correct |
17 |
Correct |
7 ms |
2132 KB |
Output is correct |
18 |
Correct |
8 ms |
2516 KB |
Output is correct |
19 |
Correct |
5 ms |
2160 KB |
Output is correct |
20 |
Correct |
6 ms |
2148 KB |
Output is correct |
21 |
Correct |
27 ms |
16656 KB |
Output is correct |
22 |
Correct |
33 ms |
20800 KB |
Output is correct |
23 |
Correct |
31 ms |
20796 KB |
Output is correct |
24 |
Correct |
29 ms |
16796 KB |
Output is correct |
25 |
Correct |
34 ms |
20808 KB |
Output is correct |
26 |
Correct |
16 ms |
6984 KB |
Output is correct |
27 |
Correct |
19 ms |
8852 KB |
Output is correct |
28 |
Correct |
15 ms |
6864 KB |
Output is correct |
29 |
Correct |
14 ms |
6992 KB |
Output is correct |
30 |
Correct |
18 ms |
9092 KB |
Output is correct |