# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
921521 | vjudge1 | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 2041 ms | 5336 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>
#define F first
#define S second
#define ent '\n'
#define int long long
#define pb push_back
typedef long double ld;
typedef long long ll;
using namespace std;
const int maxn = 1e6+12;
const int T = 0;
const int mod = 1e9+7;
int n,m,k,x,y,l,r;
int b[maxn],p[maxn],pref[maxn],fact[maxn];
char a[2222][2222];
void solve(){
cin>>n>>m>>k>>x;
int ans=0;
vector<pair<int,int>>v;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
if(a[i][j]=='S'){
v.pb({i,j});
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]=='M'){
int cal=0;
for(int u=0;u<v.size();u++){
if(max(abs(i-v[u].F) , abs(j-v[u].S)) <= k)cal++;
}
if(cal>=x)ans++;
}
}
}
cout<<ans;
}
//BEKSULTAN TOP
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
if(T)cin>>t;
while(t--)solve();
}
Compilation message (stderr)
# | 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... |