Submission #784058

#TimeUsernameProblemLanguageResultExecution timeMemory
784058rainboyCollecting Mushrooms (NOI18_collectmushrooms)C11
100 / 100
6 ms3180 KiB
#include <stdio.h> #define NM 500000 int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int main() { static char cc[NM + 1]; static int kk[NM]; int n, m, d, k, i, il, ir, j, jl, jr, cnt; scanf("%d%d%d%d", &n, &m, &d, &k); for (i = 0; i < n; i++) scanf("%s", cc + i * m); for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (cc[i * m + j] == 'S') { il = max(i - d, 0), ir = min(i + d, n - 1), jl = max(j - d, 0), jr = min(j + d, m - 1); kk[il * m + jl]++; if (jr + 1 < m) kk[il * m + (jr + 1)]--; if (ir + 1 < n) { kk[(ir + 1) * m + jl]--; if (jr + 1 < m) kk[(ir + 1) * m + (jr + 1)]++; } } for (i = 0; i < n; i++) for (j = 1; j < m; j++) kk[i * m + j] += kk[i * m + (j - 1)]; for (i = 1; i < n; i++) for (j = 0; j < m; j++) kk[i * m + j] += kk[(i - 1) * m + j]; cnt = 0; for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (cc[i * m + j] == 'M' && kk[i * m + j] >= k) cnt++; printf("%d\n", cnt); return 0; }

Compilation message (stderr)

mushrooms.c: In function 'main':
mushrooms.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d%d", &n, &m, &d, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mushrooms.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%s", cc + i * m);
      |   ^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...