Submission #1005973

#TimeUsernameProblemLanguageResultExecution timeMemory
1005973KindaNamelessCollecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
19 ms13492 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double void solve(){ int R, C, D, S; cin >> R >> C >> D >> S; vector<pair<int, int>> mushrooms; vector<vector<int>> P(R + 1, vector<int>(C + 1)); vector<vector<char>> M(R + 1, vector<char>(C + 1)); for(int i = 1; i <= R; ++i){ for(int j = 1; j <= C; ++j){ cin >> M[i][j]; if(M[i][j] == 'M'){ mushrooms.push_back({i, j}); } else if(M[i][j] == 'S'){ P[i][j] = 1; } P[i][j] += P[i][j - 1] + P[i - 1][j] - P[i - 1][j - 1]; } } int answer = 0; for(auto elem : mushrooms){ int x = elem.first, y = elem.second; int a = max(1, x - D), b = max(1, y - D), c = min(R, x + D), d = min(C, y + D); //cout << x << " " << y << " " << a << " " << b << " " << c << " " << d << "\n"; if(P[c][d] - P[a - 1][d] - P[c][b - 1] + P[a - 1][b - 1] >= S){ answer++; } } cout << answer; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; //cin >> tc; while(tc--){ solve(); } return 0; }
#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...