#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll tt=1; //cin>>tt;
while(tt--) {
ll r,c,d,k; cin>>r>>c>>d>>k;
char grid[r][c];
vector<pair<ll,ll>> mush;
for (ll i=0;i<r;i++) {
string s; cin>>s;
for (ll j=0;j<c;j++) {
grid[i][j]=s[j];
if (grid[i][j]=='M') {
pair<ll,ll> p;
p.first=i; p.second=j;
mush.push_back(p);
}
}
}
ll ans=0;
for (auto p:mush) {
ll count=0;
ll x1=p.first-d,x2=p.first+d,y1=p.second-d,y2=p.second+d;
x1=max(x1,(ll) 0); x2=min(x2,c-1);
y1=max(y1,(ll) 0); y2=min(y2,r-1);
for (ll i=x1;i<=x2;i++) {
for (ll j=y1;j<=y2;j++) {
if (grid[i][j]=='S') {
count++;
}
if (count==k) {
ans++;
break;
}
}
if (count==k) {
break;
}
}
}
cout<<ans<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
7156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |