Submission #547419

#TimeUsernameProblemLanguageResultExecution timeMemory
547419MilosMilutinovicDango Maker (JOI18_dango_maker)C++14
0 / 100
2 ms340 KiB
#include <stdio.h> #include <string.h> #define N 3000 int max(int a, int b) { return a > b ? a : b; } char s[N][N]; int dp[N + N][3], du[N][N], dr[N][N]; int main() { int n, m, i, j; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%s", s[i]); for (i = 0; i < n; i++) for (j = 0; j < m; j++) { if (j > 0 && j < m - 1 && s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W') dr[i][j] = 1; if (i > 0 && i < n - 1 && s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W') du[i][j] = 1; } memset(dp, 0, (N + N) * 3 * sizeof *dp); for (i = 0; i < n; i++) for (j = 0; j < m; j++) { int i_, dp_[3]; dp_[1] = dp_[2] = 0; dp_[0] = max(max(dp[i + j][0], dp[i + j][1]), dp[i + j][2]); if (dr[i][j] == 1) for (i_ = 0; i_ < 3; i_++) if (i_ != 2) dp_[1] = max(dp_[1], dp[i + j][i_] + 1); if (du[i][j] == 1) for (i_ = 0; i_ < 3; i_++) if (i_ != 1) dp_[2] = max(dp_[2], dp[i + j][i_] + 1); for (i_ = 0; i_ < 3; i_++) dp[i + j][i_] = dp_[i_]; } int ans = 0; for (i = 0; i < n + m; i++) ans += max(max(dp[i][0], dp[i][1]), dp[i][2]); printf("%d\n", ans); return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%s", s[i]);
      |   ~~~~~^~~~~~~~~~~~
In file included from /usr/include/string.h:495,
                 from dango_maker.cpp:2:
In function 'void* memset(void*, int, size_t)',
    inlined from 'int main()' at dango_maker.cpp:23:8:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: warning: 'void* __builtin___memset_chk(void*, int, long unsigned int, long unsigned int)' forming offset [72000, 215999] is out of the bounds [0, 72000] of object 'dp' with type 'int [6000][3]' [-Warray-bounds]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:8:19: note: 'dp' declared here
    8 | char s[N][N]; int dp[N + N][3], du[N][N], dr[N][N];
      |                   ^~
In file included from /usr/include/string.h:495,
                 from dango_maker.cpp:2:
In function 'void* memset(void*, int, size_t)',
    inlined from 'int main()' at dango_maker.cpp:23:8:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: warning: 'void* __builtin___memset_chk(void*, int, long unsigned int, long unsigned int)' forming offset [72000, 215999] is out of the bounds [0, 72000] of object 'dp' with type 'int [6000][3]' [-Warray-bounds]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:8:19: note: 'dp' declared here
    8 | char s[N][N]; int dp[N + N][3], du[N][N], dr[N][N];
      |                   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...