Submission #170449

#TimeUsernameProblemLanguageResultExecution timeMemory
170449AkashiDango Maker (JOI18_dango_maker)C++14
100 / 100
235 ms18164 KiB
#include <bits/stdc++.h> using namespace std; int n, m; int d[3010][2][2]; char s[3010][3010]; int main() { scanf("%d%d", &n, &m); for(int i = 1; i <= n ; ++i) scanf("%s", s[i] + 1); int ans = 0; for(int diag = 1; diag <= n + m - 1 ; ++diag){ int l, c; l = 1; c = diag; if(c > m) l = l + (c - m), c = m; if(l > n) c = c + (l - n), l = n; int L = min(n - l + 1, c); for(int i = 1; i <= L ; ++i) for(int j = 0; j < 2 ; ++j) for(int t = 0; t < 2 ; ++t) d[i][j][t] = 0; for(int i = 1; i <= L ; ++i, ++l, --c){ for(int j = 0; j < 2 ; ++j) for(int t = 0; t < 2 ; ++t) d[i][t][0] = max(d[i][t][0], d[i - 1][j][t]); if(s[l][c] != 'R') continue ; if(s[l + 1][c] == 'G' && s[l + 2][c] == 'W'){ for(int t = 0; t < 2 ; ++t) d[i][t][1] = max(d[i][t][1], d[i][t][0] + 1); } if(s[l][c + 1] == 'G' && s[l][c + 2] == 'W'){ d[i][0][0] = max(d[i - 1][0][0] + 1, d[i][0][0]); } } int Max = 0; for(int i = 1; i <= L ; ++i) for(int j = 0; j < 2 ; ++j) for(int t = 0; t < 2 ; ++t) Max = max(Max, d[i][j][t]); ans = ans + Max; } printf("%d", ans); return 0; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:11:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n ; ++i) scanf("%s", s[i] + 1);
                                  ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...