답안 #164787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
164787 2019-11-23T11:29:53 Z MSAAD Collecting Mushrooms (NOI18_collectmushrooms) C++17
60 / 100
29 ms 2940 KB
#include<bits/stdc++.h>
using namespace std;
char c;
bool check[501][501];
int diff[501][501];
int r,w,d,k;
int main(){
	cin>>r>>w>>d>>k;
	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;
}
				
			
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 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 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1412 KB Output is correct
2 Correct 27 ms 1528 KB Output is correct
3 Correct 29 ms 1584 KB Output is correct
4 Correct 24 ms 1400 KB Output is correct
5 Correct 26 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 2940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 4 ms 632 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 504 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 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 23 ms 1412 KB Output is correct
17 Correct 27 ms 1528 KB Output is correct
18 Correct 29 ms 1584 KB Output is correct
19 Correct 24 ms 1400 KB Output is correct
20 Correct 26 ms 1528 KB Output is correct
21 Runtime error 5 ms 2940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -