Submission #535707

#TimeUsernameProblemLanguageResultExecution timeMemory
535707makanhuliaCollecting Mushrooms (NOI18_collectmushrooms)C++17
79 / 100
2082 ms9124 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+2]; 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]++; a[ii][sn+1]--; } } } } for (long long i=1; i<=r; i++) { for (long long j=1; j<=c+1; j++) { if (j>1) { a[i][j] += a[i][j-1]; } else { a[i][j] += a[i-1][c+1]; } if (j != c+1) { 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...