답안 #538914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538914 2022-03-18T04:03:51 Z ac2hu Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
13 ms 5460 KB
#include <bits/stdc++.h>
#ifdef DEBUG
#include "../templates/debug.h"
#else 
#define deb(x...)
#endif
using namespace std;
signed main() {
	iostream::sync_with_stdio(false);
	cin.tie(nullptr);cout.tie(nullptr);
	int r,c,d,k;cin >> r >> c >> d >> k;
	vector<vector<int>> pref(r,vector<int>(c,0));
	vector<string> temp(r);
	for(auto &e : temp)cin >> e;
	for(int i = 0;i<r;i++){
		for(int j = 0;j<c;j++){
			if(temp[i][j] == 'S'){
				deb(i,j);
				pref[max(i - d,0)][max(j - d,0)]++;
				if(j + d + 1 < c){
					pref[max(i - d,0)][min(j + d + 1, c - 1)]--;
				}
				if(i + d + 1 < r){
					pref[min(i + d + 1,r - 1)][max(j - d, 0)]--;
				}
				if(i + d + 1 < r && j + d + 1 < c){
					pref[min(i + d + 1, r- 1)][min(j + d + 1,c - 1)]++;
				}
			}
		}
	}
	for(int i = 1;i<r;i++)
		pref[i][0] += pref[i - 1][0];
	for(int j = 1;j<c;j++)
		pref[0][j] += pref[0][j - 1];
	for(int i = 1;i<r;i++){
		for(int j = 1;j<c;j++){
			// if(i == )
			pref[i][j] += pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
		}
	}
	// for(int i =0 ;i<r;i++){
	// 	for(int j = 0;j<c;j++)
	// 		cout << pref[i][j] << " ";
	// 	cout << "\n";
	// }
	// cout << "---------\n";
	int cc = 0;
	for(int i = 0;i<r;i++){
		for(int j = 0;j<c;j++){
			if(temp[i][j] == 'M' && pref[i][j] >= k){
				cc++;
			}
		}
	}
	cout << cc << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 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 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1492 KB Output is correct
2 Correct 3 ms 1492 KB Output is correct
3 Correct 3 ms 1736 KB Output is correct
4 Correct 2 ms 1492 KB Output is correct
5 Correct 2 ms 1576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4180 KB Output is correct
2 Correct 7 ms 4180 KB Output is correct
3 Correct 7 ms 4180 KB Output is correct
4 Correct 9 ms 4168 KB Output is correct
5 Correct 7 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 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 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 3 ms 1492 KB Output is correct
17 Correct 3 ms 1492 KB Output is correct
18 Correct 3 ms 1736 KB Output is correct
19 Correct 2 ms 1492 KB Output is correct
20 Correct 2 ms 1576 KB Output is correct
21 Correct 8 ms 4180 KB Output is correct
22 Correct 7 ms 4180 KB Output is correct
23 Correct 7 ms 4180 KB Output is correct
24 Correct 9 ms 4168 KB Output is correct
25 Correct 7 ms 4180 KB Output is correct
26 Correct 13 ms 5460 KB Output is correct
27 Correct 8 ms 3284 KB Output is correct
28 Correct 9 ms 3288 KB Output is correct
29 Correct 7 ms 3272 KB Output is correct
30 Correct 10 ms 4596 KB Output is correct