Submission #894632

# Submission time Handle Problem Language Result Execution time Memory
894632 2023-12-28T14:41:35 Z IWKR Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
12 ms 9744 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int r, c, d, k;
	cin >> r >> c >> d >> k;
	char arr[r + 1][c + 1];
	int ss[r + 1][c + 1];
	memset(ss, 0, sizeof ss);
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> arr[i][j];
			if (arr[i][j] == 'S') {
				ss[i][j] = 1;
			} else {
				ss[i][j] = 0;
			}
			ss[i][j] = ss[i][j] + ss[i - 1][j] + ss[i][j - 1] - ss[i - 1][j - 1];
		}
	}
	int ans = 0;
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			if (arr[i][j] == 'M') {
				int x1 = i - d;
				int y1 = j - d;
				int x2 = i + d;
				int y2 = j + d;
				if (x1 <= 0) {
					x1 = 1;
				}
				if (y1 <= 0) {
					y1 = 1;
				}
				if (x2 > r) {
					x2 = r;
				}
				if (y2 > c) {
					y2 = c;
				}
				if (ss[x2][y2] - ss[x1 - 1][y2] - ss[x2][y1 - 1] + ss[x1 - 1][y1 - 1] >= k) {
					ans = ans + 1;
				}
			}
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2136 KB Output is correct
2 Correct 3 ms 2396 KB Output is correct
3 Correct 4 ms 2780 KB Output is correct
4 Correct 3 ms 2396 KB Output is correct
5 Correct 3 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9708 KB Output is correct
2 Correct 11 ms 9564 KB Output is correct
3 Correct 12 ms 9564 KB Output is correct
4 Correct 12 ms 9564 KB Output is correct
5 Correct 12 ms 9744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 3 ms 2136 KB Output is correct
17 Correct 3 ms 2396 KB Output is correct
18 Correct 4 ms 2780 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 3 ms 2396 KB Output is correct
21 Correct 12 ms 9708 KB Output is correct
22 Correct 11 ms 9564 KB Output is correct
23 Correct 12 ms 9564 KB Output is correct
24 Correct 12 ms 9564 KB Output is correct
25 Correct 12 ms 9744 KB Output is correct
26 Correct 10 ms 5208 KB Output is correct
27 Correct 9 ms 5240 KB Output is correct
28 Correct 9 ms 5208 KB Output is correct
29 Correct 9 ms 5212 KB Output is correct
30 Correct 9 ms 5384 KB Output is correct