Submission #783677

# Submission time Handle Problem Language Result Execution time Memory
783677 2023-07-15T08:21:39 Z stefdasca Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
13 ms 7636 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, m, d, k;
	cin >> n >> m >> d >> k;
	
	char grid[n+1][m+1];
	for(int i = 1; i <= n; i++)
		cin >> (grid[i] + 1);
	
	int sp[n+2][m+2];
	for(int i = 0; i <= n+1; i++)
		for(int j = 0; j <= m+1; j++)
			sp[i][j] = 0;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
		{
			if(grid[i][j] == 'S')
			{
				int La = max(1, i-d);
				int Ca = max(1, j-d);
				int Lb = min(n, i+d);
				int Cb = min(m, j+d);
				sp[La][Ca]++;
				sp[La][Cb+1]--;
				sp[Lb+1][Ca]--;
				sp[Lb+1][Cb+1]++;
			}
		}
		
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			sp[i][j] = sp[i][j] + sp[i-1][j] + sp[i][j-1] - sp[i-1][j-1];
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(sp[i][j] >= k && grid[i][j] == 'M')
				ans++;
	
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1444 KB Output is correct
2 Correct 4 ms 1456 KB Output is correct
3 Correct 5 ms 1720 KB Output is correct
4 Correct 4 ms 1492 KB Output is correct
5 Correct 4 ms 1588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 7632 KB Output is correct
2 Correct 12 ms 7528 KB Output is correct
3 Correct 12 ms 7636 KB Output is correct
4 Correct 13 ms 7632 KB Output is correct
5 Correct 12 ms 7524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 1444 KB Output is correct
17 Correct 4 ms 1456 KB Output is correct
18 Correct 5 ms 1720 KB Output is correct
19 Correct 4 ms 1492 KB Output is correct
20 Correct 4 ms 1588 KB Output is correct
21 Correct 12 ms 7632 KB Output is correct
22 Correct 12 ms 7528 KB Output is correct
23 Correct 12 ms 7636 KB Output is correct
24 Correct 13 ms 7632 KB Output is correct
25 Correct 12 ms 7524 KB Output is correct
26 Correct 12 ms 3260 KB Output is correct
27 Correct 10 ms 3256 KB Output is correct
28 Correct 13 ms 3200 KB Output is correct
29 Correct 13 ms 3284 KB Output is correct
30 Correct 13 ms 3260 KB Output is correct