Submission #321365

# Submission time Handle Problem Language Result Execution time Memory
321365 2020-11-12T08:15:19 Z techiehere08 Collecting Mushrooms (NOI18_collectmushrooms) C++14
18 / 100
11 ms 7148 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
  int n, m, k, d, ans = 0;
  scanf("%d%d%d%d", &n, &m, &k, &d);
  int dp[n + 2][m + 2];
  char grid[n + 2][m + 2];
  memset(dp, 0, sizeof dp);
  for(int i = 1; i <= n; i++){
    scanf("%s", &grid[i][1]);
    for(int j = 1; j <= m; j++){  
      //cout << grid[i][j] << " ";  
      if(grid[i][j] != 'S'){
        continue;
      }
      dp[max(1, i - d)][max(1, j - d)]++;
      dp[max(1, i - d)][min(m, j + d) + 1]--;
      dp[min(n, i + d) + 1][max(1, j - d)]--;
      dp[min(n, i + d) + 1][min(m, j + d) + 1]++;
    }
     //cout << endl;
  }
  
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      dp[i][j] += dp[i - 1][j];
    }
  }
  
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      //dp[i][j] += dp[i - 1][j];
      dp[i][j] += dp[i][j - 1];
      if(grid[i][j] == 'M' && dp[i][j] >= k){
        ans++;
      }
    }
  }
  printf("%d", ans);
  return 0;
}

Compilation message

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |   scanf("%d%d%d%d", &n, &m, &k, &d);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%s", &grid[i][1]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 7148 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -