# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733830 | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 0 ms | 0 KiB |
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>
#include<stdlib.h>
using namespace std;
char ch[500001][500001];
int d,k,p=0;
int h[500001][500001];
void range(int a , int b){
int i,j,s;
s=0;
for( i=a-d ; i<a+d ; i++){
for(j=b-d ; j<b+d ; j++){
if(ch[i][j] == 'M'){
h[i][j]+=1;
}
}
}
return;
}
int main(){
int r, c ,i,j;
cin>>r>>c>>d>>k;
for(i=1 ; i<=r ; i++){
for(j=1 ; j<=c ; j++){
cin>>ch[i][j];
}
}
for(i=1 ; i<=r ; i++){
for(j=1 ; j<=c ;j++){
if(ch[i][j] == 'S'){
range( i , j );
}
}
}
for(i=1 ; i<=r ; i++){
for(j=1 ; j<=c ;j++){
if(ch[i][j] == 'S'){
range( i , j );
}
}
}
for(i=1 ; i<=r ; i++){
for(j=1 ; j<=c ;j++){
if(h[i][j] >= k){
// cout<<h[i][j]<<endl;
// system("pause");
p++;
}
}
}
cout<<p;
return 0;
}