Submission #650757

# Submission time Handle Problem Language Result Execution time Memory
650757 2022-10-15T08:54:27 Z Shin Dango Maker (JOI18_dango_maker) C++14
0 / 100
1 ms 340 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -