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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 3000;
int N, M;
char A[MAXN+10][MAXN+10];
int dp[MAXN+10][3], ans;
int main()
{
int i, j;
scanf("%d%d", &N, &M);
for(i=1; i<=N; i++) scanf("%s", A[i]+1);
for(i=2; i<=N+M; i++)
{
int s=max(1, i-N), e=min(M, i-1);
memset(dp, 0, sizeof(dp));
for(j=s; j<=e; j++)
{
int x=j, y=i-j;
dp[x][0]=max(dp[x-1][0], max(dp[x-1][1], dp[x-1][2]));
if(A[y-1][x]=='R' && A[y][x]=='G' && A[y+1][x]=='W') dp[x][1]=max(dp[x-1][0], dp[x-1][1])+1;
if(A[y][x-1]=='R' && A[y][x]=='G' && A[y][x+1]=='W') dp[x][2]=max(dp[x-1][0], dp[x-1][2])+1;
}
ans+=max(dp[e][0], max(dp[e][1], dp[e][2]));
}
printf("%d", ans);
}
Compilation message (stderr)
dango_maker.cpp: In function 'int main()':
dango_maker.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d%d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:19:30: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | for(i=1; i<=N; i++) scanf("%s", A[i]+1);
| ~~~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |