# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
591937 | hibiki | Dango Maker (JOI18_dango_maker) | C++11 | 212 ms | 123792 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;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
int n,m;
char pic[3005][3005];
int dp[3005][3005][3];
int main()
{
scanf("%d %d",&n,&m);
for(int i = 1; i <= n; i++)
scanf("%s",pic[i] + 1);
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(pic[i][j - 1] == 'R' && pic[i][j] == 'G' && pic[i][j + 1] == 'W')
{
dp[i][j][1] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]) + 1;
}
if(pic[i - 1][j] == 'R' && pic[i][j] == 'G' && pic[i + 1][j] == 'W')
{
dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][2]) + 1;
}
}
int ans = 0;
for(int i = 1; i <= n; i++)
{
ans += max({dp[i][1][0], dp[i][1][1], dp[i][1][2]});
}
for(int j = 2; j <= m; j++)
{
ans += max({dp[n][j][0], dp[n][j][1], dp[n][j][2]});
}
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... |