답안 #586480

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586480 2022-06-30T10:24:59 Z M_W Collecting Mushrooms (NOI18_collectmushrooms) C++17
100 / 100
13 ms 8516 KB
#include <bits/stdc++.h>
#define ii pair<int, int>
using namespace std;
vector<vector<int>> v;
int ans = 0;
queue<ii> q;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N, M, D, K;
	cin >> N >> M >> D >> K;
	int rd = D * 2 + 1;
	for(int i = 0; i < N; i++){
		string line;
		cin >> line;
		vector<int> tmp;
		for(int j = 0; j < M; j++){
			int qsl = j == 0 ? 0 : tmp[j - 1];
			int qsu = i == 0 ? 0 : v[i - 1][j];
			int qslu = (i == 0 || j == 0) ? 0 : v[i - 1][j - 1];
			
			tmp.push_back(qsl + qsu - qslu + (line[j] == 'S' ? 1 : 0));
			if(line[j] == 'M') q.push({i + D, j + D});
		}
		v.push_back(tmp);
	}
	while(!q.empty()){
		auto [ni, nj] = q.front();
		int mi = min(ni, N - 1), mj = min(nj, M - 1);
		
		int qsu2 = ni - rd < 0 ? 0 : v[ni - rd][mj]; 
		int qsl2 = nj - rd < 0 ? 0 : v[mi][nj - rd];
		int qslu2 = (ni - rd < 0 || nj - rd < 0) ? 0 : v[ni - rd][nj - rd];
		
		if(v[mi][mj] - qsl2 - qsu2 + qslu2 >= K) ans++;
		q.pop();
	}
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 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 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 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 456 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1108 KB Output is correct
2 Correct 3 ms 1236 KB Output is correct
3 Correct 4 ms 1492 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 2 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5980 KB Output is correct
2 Correct 9 ms 8516 KB Output is correct
3 Correct 9 ms 7516 KB Output is correct
4 Correct 7 ms 6364 KB Output is correct
5 Correct 9 ms 8156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 456 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 2 ms 1108 KB Output is correct
17 Correct 3 ms 1236 KB Output is correct
18 Correct 4 ms 1492 KB Output is correct
19 Correct 2 ms 1356 KB Output is correct
20 Correct 2 ms 1364 KB Output is correct
21 Correct 7 ms 5980 KB Output is correct
22 Correct 9 ms 8516 KB Output is correct
23 Correct 9 ms 7516 KB Output is correct
24 Correct 7 ms 6364 KB Output is correct
25 Correct 9 ms 8156 KB Output is correct
26 Correct 13 ms 4620 KB Output is correct
27 Correct 7 ms 4692 KB Output is correct
28 Correct 7 ms 3664 KB Output is correct
29 Correct 6 ms 3412 KB Output is correct
30 Correct 11 ms 4572 KB Output is correct