제출 #555002

#제출 시각아이디문제언어결과실행 시간메모리
555002Rafi22Dango Maker (JOI18_dango_maker)C++14
13 / 100
1 ms340 KiB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

char a[6107][6107];
int DP[6107][2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=4;i<=n+3;i++) for(int j=4;j<=m+3;j++) cin>>a[i][j];
    int ans=0;
    for(int i=1;i<=n+m+6;i++)
    {
        memset(DP,0,sizeof DP);
        for(int c=1;c<=i+3;c++)
        {
            int x=c,y=i-c+1;
           // cout<<x<<" "<<y<<endl;
            DP[c+1][0]=max(DP[c+1][0],DP[c][0]);
            DP[c+1][1]=max(DP[c+1][1],DP[c][1]);
            if(y-2>0&&a[x+2][y-2]=='R'&&a[x+2][y-1]=='G'&&a[x+2][y]=='W')
            {
                DP[c+1][0]=max(DP[c+1][0],DP[c][0]+1);
                DP[c+3][1]=max(DP[c+3][1],DP[c][0]+1);
            }
            if(a[x][y]=='R'&&a[x+1][y]=='G'&&a[x+2][y]=='W')
            {
                DP[c+1][1]=max(DP[c+1][1],DP[c][1]+1);
                DP[c+3][0]=max(DP[c+3][0],DP[c][1]+1);
            }
           // cout<<DP[c][0]<<" "<<DP[c][1]<<endl;
        }
        ans+=max(DP[i+3][0],DP[i+3][1]);
        //cout<<max(DP[i+3][0],DP[i+3][1])<<endl;
    }
    cout<<ans;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...