Submission #535705

#TimeUsernameProblemLanguageResultExecution timeMemory
535705devariaotaCollecting Mushrooms (NOI18_collectmushrooms)C++17
28 / 100
14 ms9612 KiB
#include <bits/stdc++.h> using namespace std; #define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define otsumiko exit(0); #define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > > #define mikochi priority_queue<long long, vector<long long>, greater<long long> > int main() { nyahalo long long r, c, d, k, ans = 0; cin >> r >> c >> d >> k; char gr[r+1][c+1]; long long a[r+1][c+1]; memset(a, 0, sizeof(a)); for (long long i=1; i<=r; i++) { for (long long j=1; j<=c; j++) { cin >> gr[i][j]; if (gr[i][j] == 'S') { for (long long ii=max(i-d, 1ll); ii<=min(i+d, r); ii++) { long long fn = max(j-d, 1ll), sn = min(j+d, c); a[ii][fn]++; if (sn<c) { a[ii][sn+1]--; } } } } } for (long long i=1; i<=r; i++) { for (long long j=1; j<=c; j++) { if (j>1) { a[i][j] += a[i][j-1]; } else { a[i][j] += a[i-1][c]; } if (gr[i][j] == 'M' && a[i][j]>=k) { ans++; } } } cout << ans << "\n"; otsumiko }
#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...