Submission #705553

#TimeUsernameProblemLanguageResultExecution timeMemory
705553rainboyDango Maker (JOI18_dango_maker)C11
100 / 100
190 ms17940 KiB
#include <stdio.h> #include <string.h> #define N 3000 #define M 3000 int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int ft[N]; void update(int i, int n, int x) { while (i < n) { ft[i] = max(ft[i], x); i |= i + 1; } } int query(int i) { int x = 0; while (i >= 0) { x = max(x, ft[i]); i &= i + 1, i--; } return x; } int main() { static char cc[N][M + 1]; int n, m, i, j, ij, k; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%s", cc[i]); k = 0; for (ij = 0; ij <= (n - 1) + (m - 1); ij++) { memset(ft, 0, m * sizeof *ft); for (i = min(ij, n - 1), j = ij - i; i >= 0 && j < m; i--, j++) { if (j + 2 < m && cc[i][j] == 'R' && cc[i][j + 1] == 'G' && cc[i][j + 2] == 'W') update(j + 2, m, query(j + 1) + 1); if (i + 2 < n && cc[i][j] == 'R' && cc[i + 1][j] == 'G' && cc[i + 2][j] == 'W') update(j, m, query(j - 1) + 1); } k += query(m - 1); } printf("%d\n", k); return 0; }

Compilation message (stderr)

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