#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
typedef long long ll;
using namespace std;
struct range{
ll x1,x2,y1,y2;
};
ll r, c, d, k, ans;
vector<range>vec;
vector<pair<ll,ll>>shroom;
map<pair<ll,ll>,ll>mp;
bool inside(ll x, ll y){
return (x >= 1 && y >= 1 && x <= r && y <= c);
}
void check(ll x, ll y){
for(range z : vec){
if(x >= z.x1 && x <= z.x2 && y >= z.y1 && y <= z.y2){
mp[{x,y}]++;
if(mp[{x,y}] == k){
ans++;
}
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> r >> c >> d >> k;
vector<pair<ll,ll>>spr;
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
char f; cin >> f;
if(f == 'M'){
shroom.pb({i,j});
}
else if(f == 'S'){
range x;
x.x1 = i-d; x.x2 = i+d; x.y1 = j-d; x.y2 = j+d;
vec.pb(x);
}
}
}
for(pair<ll,ll> x : shroom){
check(x.fi, x.se);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1036 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
15 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1036 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
15 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
287 ms |
716 KB |
Output is correct |
9 |
Correct |
70 ms |
416 KB |
Output is correct |
10 |
Correct |
4 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
5 ms |
444 KB |
Output is correct |
3 |
Correct |
9 ms |
704 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
460 KB |
Output is correct |
2 |
Correct |
4 ms |
460 KB |
Output is correct |
3 |
Correct |
5 ms |
588 KB |
Output is correct |
4 |
Correct |
11 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2075 ms |
8448 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1036 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
588 KB |
Output is correct |
4 |
Correct |
15 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
1 ms |
312 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
287 ms |
716 KB |
Output is correct |
9 |
Correct |
70 ms |
416 KB |
Output is correct |
10 |
Correct |
4 ms |
312 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
444 KB |
Output is correct |
13 |
Correct |
9 ms |
704 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
4 ms |
460 KB |
Output is correct |
17 |
Correct |
4 ms |
460 KB |
Output is correct |
18 |
Correct |
5 ms |
588 KB |
Output is correct |
19 |
Correct |
11 ms |
564 KB |
Output is correct |
20 |
Correct |
3 ms |
556 KB |
Output is correct |
21 |
Execution timed out |
2075 ms |
8448 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |