Submission #1006038

#TimeUsernameProblemLanguageResultExecution timeMemory
1006038makanhuliaCollecting Mushrooms (NOI18_collectmushrooms)C++17
18 / 100
30 ms26744 KiB
#include <bits/stdc++.h> using namespace std; # define int long long # define fir first # define sec second # define pb push_back # define endl "\n" const int cnst = 2e5+5; bool mutipletestcase = 0; //bool debug = false; void solve() { int n, m, d, s; cin >> n >> m >> d >> s; char table[n+5][m+5]; int pre[n+5][m+5]; memset(pre, 0, sizeof(pre)); for(int i = 1; i<=n; i++) for(int j = 1; j<=m; j++) { cin >> table[i][j]; if(table[i][j] == 'S') pre[max(1ll, i-d)][max(1ll, j-d)]++, pre[min(n+1, i+d+1)][min(m+1, j+d+1)]++, pre[max(1ll, i-d)][min(m+1, j+d+1)]--, pre[min(n+1, i+d+1)][max(1ll, j-d)]--; } int ans = 0; for(int i = 1; i<=n; i++) for(int j = 1; j<=m; j++) { pre[i][j] += pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1]; // cerr << pre[i][j] << " "; // if(j == m) cerr << endl; if(table[i][j] == 'M' && pre[i][j] >= d) ans++; } cout << ans << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t = 1; if(mutipletestcase) cin >> t; while(t--) solve(); }
#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...