제출 #650757

#제출 시각아이디문제언어결과실행 시간메모리
650757ShinDango Maker (JOI18_dango_maker)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; template <class X, class Y> bool minimize(X &a, Y b) { if (a > b) return a = b, true; return false; } template <class X, class Y> bool maximize(X &a, Y b) { if (a < b) return a = b, true; return false; } const int N = 5e3 + 7; char a[N][N]; int dp[N][N][2]; signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { cin >> a[i][j]; } } int res = 0; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= m; j ++) { dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]}); if (a[i][j] == 'G' && a[i][j - 1] == 'R' && a[i][j + 1] == 'W') { maximize(dp[i][j][1], max(dp[i - 1][j + 1][1], dp[i - 1][j + 1][0]) + 1); } if (a[i][j] == 'G' && a[i - 1][j] == 'R' && a[i + 1][j] == 'W') { maximize(dp[i][j][2], max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][0]) + 1); } if (j == 1 || i == n) { res += max({dp[i][j][0], dp[i][j][1], dp[i][j][2]}); } } } cout << res; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:31:86: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   31 |       dp[i][j][0] = max({dp[i - 1][j + 1][0], dp[i - 1][j + 1][1], dp[i - 1][j + 1][2]});
      |                                                                    ~~~~~~~~~~~~~~~~~~^
dango_maker.cpp:36:28: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   36 |         maximize(dp[i][j][2], max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][0]) + 1);
      |                  ~~~~~~~~~~^
dango_maker.cpp:36:28: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
dango_maker.cpp:39:57: warning: array subscript 2 is above array bounds of 'int [2]' [-Warray-bounds]
   39 |         res += max({dp[i][j][0], dp[i][j][1], dp[i][j][2]});
      |                                               ~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...