답안 #572426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572426 2022-06-04T11:03:40 Z MODDI Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
35 ms 5676 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int r, c, d, k;
int main(){
	cin>>r>>c>>d>>k;
	char mat[r+1][c+1];
	int pref[r+1][c+1];
	memset(pref, 0, sizeof(pref));
	for(int i = 1; i <= r; i++){
      for(int j = 1; j <=c; j++){
          cin >> mat[i][j];
          pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + (mat[i][j] == 'S');
      }
  	}
	ll rez=  0;
	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			if(mat[i][j] == 'M'){
				 int a = max(i - d, 1),b = max(j - d, 1), x = min(i + d, r), y = min(j + d, c);
	          	int cr = pref[x][y] - pref[x][b- 1] - pref[a - 1][y] + pref[a - 1][b - 1];
	          	rez += (cr >= k);
			}
		}
	}
	cout<<rez<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1256 KB Output is correct
2 Correct 12 ms 1236 KB Output is correct
3 Correct 14 ms 1492 KB Output is correct
4 Correct 12 ms 1300 KB Output is correct
5 Correct 13 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 5160 KB Output is correct
2 Correct 33 ms 5580 KB Output is correct
3 Correct 35 ms 5560 KB Output is correct
4 Correct 35 ms 5544 KB Output is correct
5 Correct 32 ms 5676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 12 ms 1256 KB Output is correct
17 Correct 12 ms 1236 KB Output is correct
18 Correct 14 ms 1492 KB Output is correct
19 Correct 12 ms 1300 KB Output is correct
20 Correct 13 ms 1368 KB Output is correct
21 Correct 33 ms 5160 KB Output is correct
22 Correct 33 ms 5580 KB Output is correct
23 Correct 35 ms 5560 KB Output is correct
24 Correct 35 ms 5544 KB Output is correct
25 Correct 32 ms 5676 KB Output is correct
26 Correct 30 ms 3156 KB Output is correct
27 Correct 30 ms 3116 KB Output is correct
28 Correct 32 ms 3156 KB Output is correct
29 Correct 30 ms 3256 KB Output is correct
30 Correct 33 ms 3244 KB Output is correct