Submission #153345

#TimeUsernameProblemLanguageResultExecution timeMemory
153345AlexLuchianovCollecting Mushrooms (NOI18_collectmushrooms)C++14
100 / 100
65 ms8236 KiB
#include <iostream> #include <vector> using namespace std; #define ll long long #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) vector<vector<char>> v; vector<vector<int>> sum; int main() { int n, m, d, k; cin >> n >> m >> d >> k; v.resize(2 + n); for(int i = 0; i <= n + 1; i++) v[i].resize(2 + m); sum.resize(2 + n); for(int i = 0; i <= n + 1; i++) sum[i].resize(2 + m); for(int i = 1;i <= n; i++) for(int j = 1;j <= m; j++) { cin >> v[i][j]; if(v[i][j] == 'S'){ int x = max(1, i - d); int y = max(1, j - d); int x2 = min(1 + n, 1 + i + d); int y2 = min(1 + m, 1 + j + d); sum[x][y]++; sum[x][y2]--; sum[x2][y]--; sum[x2][y2]++; } } for(int i = 1;i <= n; i++) { for(int j = 1;j <= m; j++) { sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]; } } int result = 0; for(int i = 1;i <= n; i++) for(int j = 1; j <= m; j++) if(k <= sum[i][j] && v[i][j] == 'M') result++; cout << result; 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...