Submission #93491

# Submission time Handle Problem Language Result Execution time Memory
93491 2019-01-08T19:14:30 Z jwk Collecting Mushrooms (NOI18_collectmushrooms) C++17
0 / 100
15 ms 10124 KB
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

vector< pair<int, int> > sprinklers;
vector< pair<int, int> > mushrooms;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int R, C, D, K;
	cin >> R >> C >> D >> K;
	
	int grid[R][C];
	for(int i = 0; i < R; i++) {
		for(int j = 0; j < C; j++) {
			grid[i][j] = 0;
		}
	}
	
	for(int i = 0; i < R; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < C; j++) {
			if(s.at(j) == 'S') {
				sprinklers.pb(mp(i, j));
			}
			else if(s.at(j) == 'M') {
				mushrooms.pb(mp(i, j));
			}
		}
	}
	
	for(int i = 0; i < (signed)sprinklers.size(); i++) {
		int r = sprinklers[i].first;
		int c = sprinklers[i].second;
		
		for(int j = max(0, r - D); j <= min(R, r + D); j++) {
			for(int k = max(0, c - D); k <= min(C, c + D); k++) {
				grid[j][k]++;
				//cout << j << " " << k << endl;
			}
		}
	}
	
	int ok = 0;
	for(int i = 0; i < (signed)mushrooms.size(); i++) {
		if(grid[mushrooms[i].first][mushrooms[i].second] >= K) {
			//cout << mushrooms[i].first << " " << mushrooms[i].second << " " << grid[mushrooms[i].first][mushrooms[i].second] << endl;
			ok++;
		}
	}
	cout << ok << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 2040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 10124 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -