Submission #940853

#TimeUsernameProblemLanguageResultExecution timeMemory
940853lovrotDango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms2396 KiB
#include <cstdio> #include <algorithm> #include <vector> using namespace std; const int N = 3010; int n, m; char C[N][N]; bool stick(int x, int y, int d) { if(d == 1) return y > 0 && y < m - 1 && C[x][y] == 'G' && C[x][y - 1] == 'R' && C[x][y + 1] == 'W'; return x > 0 && x < n - 1 && C[x][y] == 'G' && C[x - 1][y] == 'R' && C[x + 1][y] == 'W'; } int DP[N][N][2]; int main() { scanf("%d%d", &n, &m); for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) scanf(" %c", &C[i][j]); int ans = 0; for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) { int *u = DP[i][j]; u[0] = 0; u[1] = stick(i, j, 1); u[2] = stick(i, j, 2); if(i > 0 && j < m - 1) { int *v = DP[i - 1][j + 1]; u[0] = max(u[0], max({v[0], v[1], v[2]})); u[1] = max(u[1], stick(i, j, 1) + max(v[0], v[1])); u[2] = max(u[2], stick(i, j, 2) + max(v[0], v[2])); } if(i == n - 1 || j == 0) ans += max({u[0], u[1], u[2]}); // printf("{%d %d %d}%c", u[0], u[1], u[2], " \n"[j == m - 1]); } printf("%d\n", ans); return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:22:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   for(int j = 0; j < m; ++j) scanf(" %c", &C[i][j]);
      |                              ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...