#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
typedef long long ll;
using namespace std;
struct water{
ll x1, x2, y1, y2;
};
ll r, c, d, k, ans;
vector<water> vec;
vector<pair<ll,ll>> M;
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(water 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(){
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'){
M.pb({i,j});
}
else if(f == 'S'){
water 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 : M){
check(x.ff, x.ss);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
604 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
10 ms |
560 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
604 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
10 ms |
560 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
171 ms |
884 KB |
Output is correct |
9 |
Correct |
43 ms |
584 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
5 ms |
592 KB |
Output is correct |
3 |
Correct |
6 ms |
716 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
2 ms |
444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
592 KB |
Output is correct |
2 |
Correct |
8 ms |
556 KB |
Output is correct |
3 |
Correct |
10 ms |
548 KB |
Output is correct |
4 |
Correct |
17 ms |
592 KB |
Output is correct |
5 |
Correct |
7 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2061 ms |
11184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
604 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
10 ms |
560 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
171 ms |
884 KB |
Output is correct |
9 |
Correct |
43 ms |
584 KB |
Output is correct |
10 |
Correct |
3 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
5 ms |
592 KB |
Output is correct |
13 |
Correct |
6 ms |
716 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
2 ms |
444 KB |
Output is correct |
16 |
Correct |
8 ms |
592 KB |
Output is correct |
17 |
Correct |
8 ms |
556 KB |
Output is correct |
18 |
Correct |
10 ms |
548 KB |
Output is correct |
19 |
Correct |
17 ms |
592 KB |
Output is correct |
20 |
Correct |
7 ms |
448 KB |
Output is correct |
21 |
Execution timed out |
2061 ms |
11184 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |