Submission #153345

# Submission time Handle Problem Language Result Execution time Memory
153345 2019-09-13T14:14:06 Z AlexLuchianov Collecting Mushrooms (NOI18_collectmushrooms) C++14
100 / 100
65 ms 8236 KB
#include <iostream>
#include <vector>

using namespace std;

#define ll long long
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

vector<vector<char>> v;
vector<vector<int>> sum;

int main()
{
  int n, m, d, k;
  cin >> n >> m >> d >> k;

  v.resize(2 + n);
  for(int i = 0; i <= n + 1; i++)
    v[i].resize(2 + m);
  sum.resize(2 + n);
  for(int i = 0; i <= n + 1; i++)
    sum[i].resize(2 + m);

  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= m; j++) {
      cin >> v[i][j];
      if(v[i][j] == 'S'){
        int x = max(1, i - d);
        int y = max(1, j - d);
        int x2 = min(1 + n, 1 + i + d);
        int y2 = min(1 + m, 1 + j + d);
        sum[x][y]++;
        sum[x][y2]--;
        sum[x2][y]--;
        sum[x2][y2]++;
      }
    }

  for(int i = 1;i <= n; i++) {
    for(int j = 1;j <= m; j++) {
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  }

  int result = 0;
  for(int i = 1;i <= n; i++)
    for(int j = 1; j <= m; j++)
      if(k <= sum[i][j] && v[i][j] == 'M')
        result++;
  cout << result;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1528 KB Output is correct
2 Correct 24 ms 1528 KB Output is correct
3 Correct 29 ms 1784 KB Output is correct
4 Correct 25 ms 1528 KB Output is correct
5 Correct 25 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 8236 KB Output is correct
2 Correct 60 ms 8220 KB Output is correct
3 Correct 60 ms 8184 KB Output is correct
4 Correct 65 ms 8096 KB Output is correct
5 Correct 62 ms 8224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 3 ms 380 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 380 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 23 ms 1528 KB Output is correct
17 Correct 24 ms 1528 KB Output is correct
18 Correct 29 ms 1784 KB Output is correct
19 Correct 25 ms 1528 KB Output is correct
20 Correct 25 ms 1660 KB Output is correct
21 Correct 62 ms 8236 KB Output is correct
22 Correct 60 ms 8220 KB Output is correct
23 Correct 60 ms 8184 KB Output is correct
24 Correct 65 ms 8096 KB Output is correct
25 Correct 62 ms 8224 KB Output is correct
26 Correct 61 ms 4992 KB Output is correct
27 Correct 57 ms 3320 KB Output is correct
28 Correct 59 ms 3448 KB Output is correct
29 Correct 57 ms 3268 KB Output is correct
30 Correct 59 ms 4600 KB Output is correct