Submission #164789

# Submission time Handle Problem Language Result Execution time Memory
164789 2019-11-23T11:32:50 Z MSAAD Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
25 ms 5276 KB
#include<bits/stdc++.h>
using namespace std;
char c;
int r,w,d,k;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>r>>w>>d>>k;
	bool check[r+1][w+1];
	int diff[r+1][w+1];
	for(int i=0;i<r;i++){
		for(int j=0;j<w;j++){
			diff[i][j]=0;
			check[i][j]=false;
		}
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<w;j++){
			cin>>c;
			if(c=='M')check[i][j]=true;
			else if(c=='S'){
				int up=max(0,i-d);
				int down=min(r-1,i+d);
				int left=max(0,j-d);
				int right=min(w-1,j+d);
				diff[up][left]++;
				diff[up][right+1]--;
				diff[down+1][left]--;
				diff[down+1][right+1]++;
			}
		}
	}
	for(int i=1;i<w;i++) diff[0][i]+=diff[0][i-1];
	for(int i=1;i<r;i++) diff[i][0]+=diff[i-1][0];
	for(int i=1;i<=r;i++){
		for(int j=1;j<=w;j++)
			diff[i][j]+=diff[i-1][j]+diff[i][j-1]-diff[i-1][j-1];
	}
//	for(int i=0;i<r;i++){
//		for(int j=0;j<w;j++)
//			cout<<diff[i][j]<<" ";
//		cout<<endl;
//	}
	int ans=0;
	for(int i=0;i<r;i++)
		for(int j=0;j<w;j++)
			if(check[i][j]==true && diff[i][j]>=k)
				ans++;
	cout<<ans<<endl;
	return 0;
}
				
			
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 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 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 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 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 2 ms 376 KB Output is correct
4 Correct 2 ms 296 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1272 KB Output is correct
2 Correct 8 ms 1400 KB Output is correct
3 Correct 9 ms 1528 KB Output is correct
4 Correct 7 ms 1400 KB Output is correct
5 Correct 18 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 5240 KB Output is correct
2 Correct 25 ms 5276 KB Output is correct
3 Correct 21 ms 5240 KB Output is correct
4 Correct 23 ms 5240 KB Output is correct
5 Correct 20 ms 5240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 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 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 2 ms 376 KB Output is correct
14 Correct 2 ms 296 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 7 ms 1272 KB Output is correct
17 Correct 8 ms 1400 KB Output is correct
18 Correct 9 ms 1528 KB Output is correct
19 Correct 7 ms 1400 KB Output is correct
20 Correct 18 ms 1528 KB Output is correct
21 Correct 22 ms 5240 KB Output is correct
22 Correct 25 ms 5276 KB Output is correct
23 Correct 21 ms 5240 KB Output is correct
24 Correct 23 ms 5240 KB Output is correct
25 Correct 20 ms 5240 KB Output is correct
26 Correct 18 ms 3320 KB Output is correct
27 Correct 17 ms 3320 KB Output is correct
28 Correct 19 ms 3316 KB Output is correct
29 Correct 18 ms 3320 KB Output is correct
30 Correct 18 ms 3448 KB Output is correct