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>
#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 |
---|
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... |