답안 #263819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263819 2020-08-14T02:27:34 Z T0p_ Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
45 ms 16752 KB
#include<bits/stdc++.h>
using namespace std;

vector<pair<int, int>> mushroom;

int main()
{
	int n, m, d, w;
	scanf(" %d %d %d %d",&n,&m,&d,&w);
	int qs[n+5][m+5];
	memset(qs, 0, sizeof qs);
	for(int i=1 ; i<=n ; i++)
		for(int j=1 ; j<=m ; j++)
		{
			char c;
			scanf(" %c",&c);
			if(c == 'M') mushroom.push_back({i, j});
			else if(c == 'S')
			{
				int si = max(1, i-d), sj = max(1, j-d), ei = min(n, i+d), ej = min(m, j+d);
				qs[si][sj]++;
				qs[si][ej+1]--;
				qs[ei+1][sj]--;
				qs[ei+1][ej+1]++;
			}
		}
	for(int i=1 ; i<=n ; i++)
		for(int j=1 ; j<=m ; j++)
			qs[i][j] += qs[i-1][j] + qs[i][j-1] - qs[i-1][j-1];
	int ans = 0;
	for(auto x : mushroom)
		if(qs[x.first][x.second] >= w) ans++;
	printf("%d\n",ans);
	return 0;
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf(" %d %d %d %d",&n,&m,&d,&w);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:16:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |    scanf(" %c",&c);
      |    ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1280 KB Output is correct
2 Correct 13 ms 1280 KB Output is correct
3 Correct 18 ms 1536 KB Output is correct
4 Correct 14 ms 1280 KB Output is correct
5 Correct 16 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 14580 KB Output is correct
2 Correct 45 ms 16752 KB Output is correct
3 Correct 43 ms 16752 KB Output is correct
4 Correct 42 ms 14708 KB Output is correct
5 Correct 43 ms 16752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 13 ms 1280 KB Output is correct
17 Correct 13 ms 1280 KB Output is correct
18 Correct 18 ms 1536 KB Output is correct
19 Correct 14 ms 1280 KB Output is correct
20 Correct 16 ms 1408 KB Output is correct
21 Correct 41 ms 14580 KB Output is correct
22 Correct 45 ms 16752 KB Output is correct
23 Correct 43 ms 16752 KB Output is correct
24 Correct 42 ms 14708 KB Output is correct
25 Correct 43 ms 16752 KB Output is correct
26 Correct 33 ms 4332 KB Output is correct
27 Correct 41 ms 4852 KB Output is correct
28 Correct 35 ms 4088 KB Output is correct
29 Correct 34 ms 4124 KB Output is correct
30 Correct 34 ms 5224 KB Output is correct