# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
650757 | Shin | Dango Maker (JOI18_dango_maker) | C++14 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |