#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
vector< pair<int, int> > sprinklers;
vector< pair<int, int> > mushrooms;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int R, C, D, K;
cin >> R >> C >> D >> K;
int grid[R][C];
for(int i = 0; i < R; i++) {
for(int j = 0; j < C; j++) {
grid[i][j] = 0;
}
}
for(int i = 0; i < R; i++) {
string s;
cin >> s;
for(int j = 0; j < C; j++) {
if(s.at(j) == 'S') {
sprinklers.pb(mp(i, j));
}
else if(s.at(j) == 'M') {
mushrooms.pb(mp(i, j));
}
}
}
for(int i = 0; i < sprinklers.size(); i++) {
int r = sprinklers[i].first;
int c = sprinklers[i].second;
for(int j = max(0, r - D); j <= min(R, r + D); j++) {
for(int k = max(0, c - D); k <= min(C, c + D); k++) {
grid[j][k]++;
//cout << j << " " << k << endl;
}
}
}
int ok = 0;
for(int i = 0; i < mushrooms.size(); i++) {
if(grid[mushrooms[i].first][mushrooms[i].second] >= K) {
//cout << mushrooms[i].first << " " << mushrooms[i].second << " " << grid[mushrooms[i].first][mushrooms[i].second] << endl;
ok++;
}
}
cout << ok << endl;
return 0;
}
Compilation message
mushrooms.cpp: In function 'int main()':
mushrooms.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < sprinklers.size(); i++) {
~~^~~~~~~~~~~~~~~~~~~
mushrooms.cpp:51:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < mushrooms.size(); i++) {
~~^~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
10 ms |
2168 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
16 ms |
10512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
7 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |