This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
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 ans = 0;
int prefix[r + 2][c + 2];
vector<pair<int, int>>v;
memset(prefix, 0, sizeof(prefix));
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
char x; cin >> x;
prefix[i][j] = prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1] + (x == 'S');
if(x == 'M') v.emplace_back(i, j);
}
}
for(auto &[x, y]: v){
int TLX = max(1, (x - d));
int TLY = max(1, (y - d));
int BRX = min(r, (x + d));
int BRY = min(c, (y + d));
int tmp = prefix[BRX][BRY] - prefix[BRX][TLY - 1] - prefix[TLX - 1][BRY] + prefix[TLX - 1][TLY - 1];
ans += (tmp >= k);
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |