Submission #224776

# Submission time Handle Problem Language Result Execution time Memory
224776 2020-04-18T18:55:27 Z Nightlight Collecting Mushrooms (NOI18_collectmushrooms) C++14
38 / 100
55 ms 8416 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;

int R, C, D, K, P, ans;
vector<vector<int>> pre;
pii mus[500005];
char t;

int getsum(int x,int y) {
  int y1 = min(y + D, C), y0 = max(y - D - 1, 0);
  int x1 = min(x + D, R), x0 = max(x - D - 1, 0);
  return pre[x1][y1] - pre[x1][y0] - pre[x0][y1] - pre[x0][y0];
}

int main() {
//  freopen("inp", "r", stdin);
  scanf("%d %d %d %d", &R, &C, &D, &K);
  pre.resize(R + 5);
  pre[0].resize(C + 5);
  getchar();
  for(int i = 1; i <= R; i++) {
    pre[i].resize(C + 5);
    for(int j = 1; j <= C; j++) {
      pre[i][j] = pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1];
      cin >> t;
      if(t == 'M') {
        mus[++P] = {i, j};
      }else if(t == 'S') {
        pre[i][j]++;
      }
    }
    getchar();
  }
  for(int i = 1; i <= P; i++) {
    if(getsum(mus[i].x, mus[i].y) >= K) ans++;
  }
  printf("%d\n", ans);
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d %d", &R, &C, &D, &K);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1280 KB Output is correct
2 Incorrect 23 ms 1400 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6008 KB Output is correct
2 Correct 54 ms 8416 KB Output is correct
3 Correct 55 ms 7544 KB Output is correct
4 Correct 52 ms 6272 KB Output is correct
5 Correct 53 ms 8056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -