Submission #141077

# Submission time Handle Problem Language Result Execution time Memory
141077 2019-08-06T14:52:44 Z tincamatei Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
47 ms 7488 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
	int R, C, D, K;

	vector<string> matr;
	vector<vector<int> > smen;
	
	cin >> R >> C >> D >> K;
	for(int i = 0; i < R; ++i) {
		string str;
		cin >> str;
		matr.push_back(str);
	}

	smen = vector<vector<int> >(R + 1, vector<int>(C + 1, 0));

	for(int l = 0; l < R; ++l)
		for(int c = 0; c < C; ++c)
			if(matr[l][c] == 'S') {
				int l1, c1, l2, c2;
				l1 = max(0, l - D);
				l2 = min(R, l + D + 1);
				c1 = max(0, c - D);
				c2 = min(C, c + D + 1);

				smen[l1][c1]++;
				smen[l1][c2]--;
				smen[l2][c1]--;
				smen[l2][c2]++;
			}
	
	int rez = 0;
	for(int l = 0; l < R; ++l) {
		int p = 0;
		for(int c = 0; c < C; ++c) {
			p += smen[l][c];
			smen[l + 1][c] += smen[l][c];

			if(matr[l][c] == 'M' && p >= K)
				++rez;
		}
	}

	printf("%d", rez);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1364 KB Output is correct
2 Correct 15 ms 1528 KB Output is correct
3 Correct 18 ms 1784 KB Output is correct
4 Correct 15 ms 1524 KB Output is correct
5 Correct 16 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 6844 KB Output is correct
2 Correct 38 ms 7444 KB Output is correct
3 Correct 39 ms 7232 KB Output is correct
4 Correct 45 ms 7364 KB Output is correct
5 Correct 43 ms 7488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 15 ms 1364 KB Output is correct
17 Correct 15 ms 1528 KB Output is correct
18 Correct 18 ms 1784 KB Output is correct
19 Correct 15 ms 1524 KB Output is correct
20 Correct 16 ms 1656 KB Output is correct
21 Correct 40 ms 6844 KB Output is correct
22 Correct 38 ms 7444 KB Output is correct
23 Correct 39 ms 7232 KB Output is correct
24 Correct 45 ms 7364 KB Output is correct
25 Correct 43 ms 7488 KB Output is correct
26 Correct 47 ms 5100 KB Output is correct
27 Correct 36 ms 3452 KB Output is correct
28 Correct 37 ms 3320 KB Output is correct
29 Correct 36 ms 3320 KB Output is correct
30 Correct 44 ms 4580 KB Output is correct