Submission #535705

# Submission time Handle Problem Language Result Execution time Memory
535705 2022-03-11T01:37:00 Z devariaota Collecting Mushrooms (NOI18_collectmushrooms) C++17
28 / 100
14 ms 9612 KB
#include <bits/stdc++.h>
using namespace std;

#define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define otsumiko exit(0);
#define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >
#define mikochi priority_queue<long long, vector<long long>, greater<long long> >

int main() {
  nyahalo
  long long r, c, d, k, ans = 0;
  cin >> r >> c >> d >> k;
  char gr[r+1][c+1];
  long long a[r+1][c+1];
  memset(a, 0, sizeof(a));
  for (long long i=1; i<=r; i++) {
    for (long long j=1; j<=c; j++) {
      cin >> gr[i][j];
      if (gr[i][j] == 'S') {
        for (long long ii=max(i-d, 1ll); ii<=min(i+d, r); ii++) {
          long long fn = max(j-d, 1ll), sn = min(j+d, c);
          a[ii][fn]++;
          if (sn<c) {
            a[ii][sn+1]--;
          }
        }
      }
    }
  }
  for (long long i=1; i<=r; i++) {
    for (long long j=1; j<=c; j++) {
      if (j>1) {
        a[i][j] += a[i][j-1];
      } else {
        a[i][j] += a[i-1][c];
      }
      if (gr[i][j] == 'M' && a[i][j]>=k) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  otsumiko
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 2 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9120 KB Output is correct
2 Correct 13 ms 9552 KB Output is correct
3 Correct 11 ms 9612 KB Output is correct
4 Correct 14 ms 9556 KB Output is correct
5 Correct 14 ms 9548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Incorrect 2 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -