Submission #1151531

#TimeUsernameProblemLanguageResultExecution timeMemory
1151531MedetbekCollecting Mushrooms (NOI18_collectmushrooms)C++20
60 / 100
2095 ms9032 KiB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include <bits/stdc++.h>

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
#define nl '\n'
#define pb push_back
#define sz(s) (int)(s).size()
#define f first
#define s second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
const ll N = 2e5+10, MX = 1e18+1, MOD = 1e9 + 7;
void solve(){
    ll n, m, d, k;
    cin >> n >> m >> d >> k;
    char a[n+1][m+1];
    ll w[n+1][m+1];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
            w[i][j]=0;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] != 'S')continue;
            for(int x = max(1ll,i-d); x <= min(n, i+d); x++){
                for(int y = max(1ll,j-d); y <= min(m,j+d); y++){
                    w[x][y]++;
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] == 'M' && w[i][j] >= k){
                ans++;
            }
        }
    }
    cout << ans;
}
main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll ql =1;
    //cin>>ql;
	 while(ql--){
	    solve();
	}
}

Compilation message (stderr)

mushrooms.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...