# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1262177 | Bui_Quoc_Cuong | Dango Maker (JOI18_dango_maker) | C++20 | 134 ms | 9292 KiB |
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<=(int)b;i++)
#define FORD(i,a,b) for(int i=a;i>=(int)b;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(A) A.begin(), A.end()
#define BIT(mask,i) ((mask>>(i))&1)
template <class A, class B> bool maximize(A &a, const B b) {if(a<b){a = b;return 1;} return 0;}
template <class A, class B> bool minimize(A &a, const B b) {if(a>b){a = b;return 1;} return 0;}
int n,m;
char a[3005][3005];
void init()
{
cin >> n >> m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin >> a[i][j];
}
}
}
void process()
{
int ans = 0;
for(int c = 1; c <= n + m; c++)
{
vector <int> f1(m + 6, 0);
vector <int> f2(m + 6, 0);
int mx = 0;
for(int j = min(m, c - 1), i = c - j; j >= 1 && i <= n; j--, i++)
{
f1[j] = max(f1[j + 1], f2[j + 3]) + (a[i][j] == 'R' && a[i][j + 1] == 'G' && a[i][j + 2] == 'W');
f2[j] = max(f1[j + 1], f2[j + 1]) + (a[i][j] == 'R' && a[i + 1][j] == 'G' && a[i + 2][j] == 'W');
maximize(mx, max(f1[j], f2[j]));
}
ans+= mx;
}
cout << ans;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#define Hori "dango"
if(fopen(Hori".inp", "r"))
{
freopen(Hori".inp", "r", stdin);
freopen(Hori".out", "w", stdout);
}
init();
process();
return 0;
}
/*
3 4
RGWR
GRGG
RGWW
*/
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... |