#include <iostream>
#include <iomanip>
#include <array>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <bitset>
#include <climits>
#include <valarray>
#include <list>
#include <functional>
#include <unordered_map>
#define int long long int
#define inf 100000000000
#define endl '\n'
#define mod 998244353
using namespace std;
signed main(){
int r,c,d,k; cin >> r >> c >> d >> k;
char ar[r+1][c+1];
int val[r+1][c+1];
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
cin >> ar[i][j];
val[i][j] = 0;
}
}
for (int i = 0; i <= r; i++) val[i][0] = 0;
for (int i = 0; i <= c; i++) val[0][i] = 0;
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
if (ar[i][j] != 'S') continue;
int ci = max(i-d,1LL);
int cj = max(j-d,1LL);
if (ci >= 1 && cj >= 1) val[ci][cj]++;
ci = max(i-d, 1LL);
cj = j+d+1;
if (ci >= 1 && cj <= c) val[ci][cj]--;
ci = i+d+1;
cj = j-d;
if (ci <= r && cj >= 1) val[ci][cj]--;
// ci = min(i+d+1, r);
// cj = min(j+d+1, c);
// if (ci <= r && cj <= r) val[ci][cj]++;
}
}
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
val[i][j] += val[i-1][j];
val[i][j] += val[i][j-1];
val[i][j] -= val[i-1][j-1];
//cout << val[i][j] << " ";
}
//cout << endl;
}
int cnt = 0;
for (int i = 1; i <= r; i++){
for (int j = 1; j <= c; j++){
//if (i == 3 && j == 4) cout << ar[i][j] << " " << val[i][j] << endl;
if (ar[i][j] == 'M' && val[i][j] >= k) cnt++;
}
}
cout << cnt << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
2232 KB |
Output is correct |
2 |
Incorrect |
13 ms |
2240 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
40 ms |
9568 KB |
Output is correct |
2 |
Correct |
40 ms |
9548 KB |
Output is correct |
3 |
Correct |
38 ms |
9584 KB |
Output is correct |
4 |
Correct |
36 ms |
9572 KB |
Output is correct |
5 |
Correct |
38 ms |
9548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |