Submission #1082337

# Submission time Handle Problem Language Result Execution time Memory
1082337 2024-08-31T07:41:09 Z vuavisao Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
14 ms 29788 KB
#include <bits/stdc++.h>
using namespace std;

const int N = (int) 5e5 + 10;

int numRows, numCols, dist, cnt;
string s[N];

vector<vector<int>> pred;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cin >> numRows >> numCols >> dist >> cnt;
	pred.resize(numRows + 5, vector<int>(numCols + 5, 0));
	for (int i = 1; i <= numRows; ++ i) {
		cin >> s[i]; s[i] = ' ' + s[i];
		for (int j = 1; j <= numCols; ++ j) {
			if (s[i][j] == 'S') {
				int le = max(1, j - dist);
				int ri = min(numCols, j + dist);
				int up = max(1, i - dist);
				int down = min(numRows, i + dist);
				++ pred[up][le];
				-- pred[up][ri + 1];
				-- pred[down + 1][le];
				++ pred[down + 1][ri + 1];
			}
		}
	}
	int res = 0;
	for (int i = 1; i <= numRows; ++ i) {
		for (int j = 1; j <= numCols; ++ j) {
			pred[i][j] += pred[i - 1][j] + pred[i][j - 1] - pred[i - 1][j - 1];
			if (s[i][j] == 'M' && pred[i][j] >= cnt) ++ res;
		}
	}
	cout << res;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 3 ms 15964 KB Output is correct
4 Correct 3 ms 15964 KB Output is correct
5 Correct 2 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 3 ms 15964 KB Output is correct
4 Correct 3 ms 15964 KB Output is correct
5 Correct 2 ms 15964 KB Output is correct
6 Correct 3 ms 15964 KB Output is correct
7 Correct 3 ms 15964 KB Output is correct
8 Correct 3 ms 15964 KB Output is correct
9 Correct 3 ms 15964 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 15964 KB Output is correct
2 Correct 2 ms 16008 KB Output is correct
3 Correct 3 ms 15964 KB Output is correct
4 Correct 2 ms 15964 KB Output is correct
5 Correct 2 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 16988 KB Output is correct
2 Correct 4 ms 16988 KB Output is correct
3 Correct 5 ms 17240 KB Output is correct
4 Correct 5 ms 16988 KB Output is correct
5 Correct 4 ms 16988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 29788 KB Output is correct
2 Correct 11 ms 29788 KB Output is correct
3 Correct 11 ms 29788 KB Output is correct
4 Correct 14 ms 29788 KB Output is correct
5 Correct 11 ms 29788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 3 ms 15964 KB Output is correct
4 Correct 3 ms 15964 KB Output is correct
5 Correct 2 ms 15964 KB Output is correct
6 Correct 3 ms 15964 KB Output is correct
7 Correct 3 ms 15964 KB Output is correct
8 Correct 3 ms 15964 KB Output is correct
9 Correct 3 ms 15964 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
11 Correct 3 ms 15964 KB Output is correct
12 Correct 2 ms 16008 KB Output is correct
13 Correct 3 ms 15964 KB Output is correct
14 Correct 2 ms 15964 KB Output is correct
15 Correct 2 ms 15964 KB Output is correct
16 Correct 4 ms 16988 KB Output is correct
17 Correct 4 ms 16988 KB Output is correct
18 Correct 5 ms 17240 KB Output is correct
19 Correct 5 ms 16988 KB Output is correct
20 Correct 4 ms 16988 KB Output is correct
21 Correct 13 ms 29788 KB Output is correct
22 Correct 11 ms 29788 KB Output is correct
23 Correct 11 ms 29788 KB Output is correct
24 Correct 14 ms 29788 KB Output is correct
25 Correct 11 ms 29788 KB Output is correct
26 Correct 12 ms 20316 KB Output is correct
27 Correct 7 ms 18528 KB Output is correct
28 Correct 8 ms 18780 KB Output is correct
29 Correct 6 ms 18772 KB Output is correct
30 Correct 10 ms 19624 KB Output is correct