Submission #170349

# Submission time Handle Problem Language Result Execution time Memory
170349 2019-12-24T20:23:34 Z ngmh Collecting Mushrooms (NOI18_collectmushrooms) C++11
100 / 100
82 ms 28516 KB
#include <bits/stdc++.h>
using namespace std;

int r, c, d, k, h, nx1, nx2, ny1, ny2;
char t;
vector<pair<int, int> > mushrooms;
int main(){
	cin >> r >> c >> d >> k;
	int grid[r+5][c+5], sums[r+5][c+5];
	memset(grid, 0, sizeof(grid));
	memset(sums, 0, sizeof(sums));
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			cin >> t;	
			if(t == 'S') grid[i][j] = 1;
			else if(t == 'M') mushrooms.push_back(make_pair(i, j));
		}
	}
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			 sums[i][j] = sums[i-1][j] + sums[i][j-1] - sums[i-1][j-1] + grid[i][j];
		}
	}
	for(int i = 0; i < mushrooms.size(); i++){
		nx1 = max(1, mushrooms[i].first-d);
		nx2 = min(r, mushrooms[i].first+d);
		ny1 = max(1, mushrooms[i].second-d);
		ny2 = min(c, mushrooms[i].second+d);
		if((sums[nx2][ny2] - sums[nx1-1][ny2] - sums[nx2][ny1-1] + sums[nx1-1][ny1-1]) >= k) h++;
	}
	cout << h;
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:24:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < mushrooms.size(); i++){
                 ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 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 256 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 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 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 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 2 ms 376 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2040 KB Output is correct
2 Correct 23 ms 2168 KB Output is correct
3 Correct 28 ms 2552 KB Output is correct
4 Correct 24 ms 2240 KB Output is correct
5 Correct 25 ms 2296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 26352 KB Output is correct
2 Correct 82 ms 28492 KB Output is correct
3 Correct 81 ms 28512 KB Output is correct
4 Correct 78 ms 26600 KB Output is correct
5 Correct 82 ms 28516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 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 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 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 2 ms 376 KB Output is correct
13 Correct 3 ms 632 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 23 ms 2040 KB Output is correct
17 Correct 23 ms 2168 KB Output is correct
18 Correct 28 ms 2552 KB Output is correct
19 Correct 24 ms 2240 KB Output is correct
20 Correct 25 ms 2296 KB Output is correct
21 Correct 78 ms 26352 KB Output is correct
22 Correct 82 ms 28492 KB Output is correct
23 Correct 81 ms 28512 KB Output is correct
24 Correct 78 ms 26600 KB Output is correct
25 Correct 82 ms 28516 KB Output is correct
26 Correct 59 ms 6704 KB Output is correct
27 Correct 61 ms 6888 KB Output is correct
28 Correct 59 ms 6256 KB Output is correct
29 Correct 58 ms 6384 KB Output is correct
30 Correct 60 ms 7408 KB Output is correct