# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1269525 | ducdev | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 16 ms | 16988 KiB |
// Author: 4uckd3v - Nguyen Cao Duc
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1e6;
const int MOD = 1e9 + 7;
int m, n, d, k;
vector<vector<char>> a;
vector<vector<int>> pref;
void updateRange(int i, int j) {
int x = max(1, i - d), y = max(1, j - d);
int u = min(m, i + d), v = min(n, j + d);
pref[x][y]++, pref[u + 1][v + 1]++;
pref[u + 1][y]--, pref[x][v + 1]--;
};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
if (fopen("MAIN.INP", "r")) {
freopen("MAIN.INP", "r", stdin);
freopen("MAIN.OUT", "w", stdout);
};
cin >> m >> n >> d >> k;
a.resize(m + 5, vector<char>(n + 5));
pref.resize(m + 5, vector<int>(n + 5, 0));
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
if (a[i][j] == 'S') updateRange(i, j);
};
};
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
};
};
int res = 0;
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {
if (a[i][j] == 'M' && pref[i][j] >= k) res++;
};
};
cout << res << '\n';
};
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |