# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757091 | qwertyqwerty | Dango Maker (JOI18_dango_maker) | C++14 | 2 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.
// stars only shine in darkness
#include <bits/stdc++.h>
// date:12-06-2023 21:32:47
using namespace std;
#define retardlord ios_base::sync_with_stdio(NULL), cin.tie(NULL);
#define task freopen("dangomaker.inp", "r", stdin), freopen("dangomaker.out", "w", stdout);
const int N = 3e3 + 1;
int n, m;
char a[N][N];
int f[3], f1[3];
//--------------------------------------------------------------------------------------------------
void nhap()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
}
//--------------------------------------------------------------------------------------------------
void xuly()
{
int ans = 0;
for (int i = 2; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (a[i][j] == 'G')
{
f1[0] = f1[1] = f1[2] = -1e7;
f1[0] = max({f[0], f[1], f[2]});
if (j - 1 >= 1 && j + 1 <= m && a[i][j - 1] == 'R' && a[i][j + 1] == 'W')
f1[1] = max(f[0], f[1]) + 1;
if (i - 1 >= 1 && i + 1 <= n && a[i - 1][j] == 'R' && a[i + 1][j] == 'W')
f1[2] = max(f[0], f[2]) + 1;
f[0] = f1[0], f[1] = f1[1], f[2] = f1[2];
}
else
{
f[0] = max({f[0], f[1], f[2]});
f[1] = f[2] = -1e7;
}
}
ans += max({f[0], f[1], f[2]});
}
cout << ans;
}
//--------------------------------------------------------------------------------------------------
signed main()
{
retardlord;
#ifndef ONLINE_JUDGE
task;
#endif
nhap();
xuly();
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... |