# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1005969 | makanhulia | Collecting Mushrooms (NOI18_collectmushrooms) | C++17 | 8 ms | 9180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, d, s;
cin >> n >> m >> d >> s;
string grid[n + 1];
for ( int i = 0; i < n; i++) cin >> grid[i];
vector < int > a ( n + 5), b ( n + 5);
vector < pair < int, int > > tanaman;
for ( int i = 0; i < n; i++){
for ( int j = 0; j < m; j++){
if ( grid[i][j] == 'M' ){
tanaman.push_back({i, j});
}
if ( grid[i][j] == 'S' ){
int xmn = max ( 0ll, i - d);
int xmx = min ( n, i + d );
a[xmn]++;
a[xmx + 1]--;
int ymn = max ( 0ll, j - d);
int ymx = min ( m, j + d);
b[ymn]++;
b[xmx + 1]--;
}
}
}
for ( int i = 1; i < n; i++) a[i] += a[i - 1];
for ( int i = 1; i < m; i++) a[i] += b[i - 1];
int cnt = 0;
for ( int i = 0; i < tanaman.size(); i++){
int x = tanaman[i].first, y = tanaman[i].second;
int mx = max ( a[x], b[y] );
if ( mx >= s ) cnt++;
}
cout << cnt << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |