# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170253 | ZwariowanyMarcin | Dango Maker (JOI18_dango_maker) | C++14 | 441 ms | 164728 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
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)
using namespace std;
const int nax = 3111;
void maxi(int &a, int b) {
a = max(a, b);
}
int n, m;
char s[nax][nax];
bool in(int r, int c) {
return 1 <= r && r <= n && 1 <= c && c <= m;
}
int dp[nax][nax][2][2];
int daj(int r, int c) {
int naj = 0;
for(int i = 0; i < 2; ++i)
for(int j = 0; j < 2; ++j)
maxi(naj, dp[r][c][i][j]);
return naj;
}
int main() {
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; ++i)
scanf("%s", s[i] + 1);
for(int r = 1; r <= n; ++r)
for(int c = m; 1 <= c; --c)
for(int g = 0; g < 2; ++g)
for(int d = 0; d < 2; ++d) {
maxi(dp[r][c][0][0], dp[r - 1][c + 1][g][d]);
if(!(s[r][c] == 'G')) continue;
if(in(r - 1, c) && s[r - 1][c] == 'R' && g == 0)
if(in(r + 1, c) && s[r + 1][c] == 'W')
maxi(dp[r][c][0][1], dp[r - 1][c + 1][g][d] + 1);
if(in(r, c + 1) && s[r][c + 1] == 'W' && d == 0)
if(in(r, c - 1) && s[r][c - 1] == 'R')
maxi(dp[r][c][1][0], dp[r - 1][c + 1][g][d] + 1);
}
int ans = 0;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
if(i == n || j == 1)
ans += daj(i, j);
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... |