# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163429 | iefnah06 | Dango Maker (JOI18_dango_maker) | C++11 | 319 ms | 18168 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>
using namespace std;
const int MAXL = 3010;
int X, Y;
char G[MAXL][MAXL];
int main() {
scanf("%d %d", &X, &Y);
for (int x = 1; x <= X; x++) {
scanf("%s", G[x] + 1);
}
int ans = 0;
for (int xpy = 1; xpy <= X + Y; xpy++) {
array<int, 3> dp = {};
for (int x = 1; x <= X; x++) {
int y = xpy - x;
if (y < 1 || y > Y) continue;
array<int, 3> ndp = {};
// horizontal
if (G[x][y - 1] == 'R' && G[x][y] == 'G' && G[x][y + 1] == 'W') {
ndp[0] = 1 + max(dp[0], dp[2]);
}
// vertical
if (G[x - 1][y] == 'R' && G[x][y] == 'G' && G[x + 1][y] == 'W') {
ndp[1] = 1 + max(dp[1], dp[2]);
}
// do nothing
ndp[2] = *max_element(dp.begin(), dp.end());
swap(dp, ndp);
}
ans += *max_element(dp.begin(), dp.end());
}
printf("%d\n", ans);
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... |