Submission #535707

# Submission time Handle Problem Language Result Execution time Memory
535707 2022-03-11T01:45:43 Z makanhulia Collecting Mushrooms (NOI18_collectmushrooms) C++17
79 / 100
2000 ms 9124 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+2];
  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]++;
          a[ii][sn+1]--;
        }
      }
    }
  }
  for (long long i=1; i<=r; i++) {
    for (long long j=1; j<=c+1; j++) {
      if (j>1) {
        a[i][j] += a[i][j-1];
      } else {
        a[i][j] += a[i-1][c+1];
      }
      if (j != c+1) {
        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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 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 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 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 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2004 KB Output is correct
2 Correct 4 ms 2212 KB Output is correct
3 Correct 5 ms 2760 KB Output is correct
4 Correct 5 ms 2344 KB Output is correct
5 Correct 5 ms 2464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 9044 KB Output is correct
2 Correct 12 ms 9044 KB Output is correct
3 Correct 11 ms 9120 KB Output is correct
4 Correct 14 ms 9124 KB Output is correct
5 Correct 13 ms 9044 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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 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 1 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 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2004 KB Output is correct
17 Correct 4 ms 2212 KB Output is correct
18 Correct 5 ms 2760 KB Output is correct
19 Correct 5 ms 2344 KB Output is correct
20 Correct 5 ms 2464 KB Output is correct
21 Correct 12 ms 9044 KB Output is correct
22 Correct 12 ms 9044 KB Output is correct
23 Correct 11 ms 9120 KB Output is correct
24 Correct 14 ms 9124 KB Output is correct
25 Correct 13 ms 9044 KB Output is correct
26 Execution timed out 2082 ms 5272 KB Time limit exceeded
27 Halted 0 ms 0 KB -