Submission #75155

#TimeUsernameProblemLanguageResultExecution timeMemory
75155bogdan10bosDango Maker (JOI18_dango_maker)C++14
100 / 100
416 ms113424 KiB
#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

int N, M, ans;
char a[3005][3005];
int dp[3005][3][3];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d\n", &N, &M);
    for(int i = 1; i <= N; i++)
        scanf("%s", a[i] + 1);

    for(int l = 4; l <= N + M; l++)
    {
        int st = max(1, l - M);
        for(int i = 1; i <= N; i++)
            for(int j = 0; j < 3; j++)
                for(int k = 0; k < 3; k++)
                    dp[i][j][k] = 0;

        int mx = 0;
        for(int i = st; i <= N && i < l; i++)
        {
            int x = i, y = l - i;
            for(int j = 0; j < 3; j++)
                for(int k = 0; k < 3; k++)
                    dp[i][j][0] = max(dp[i][j][0], dp[i - 1][k][j]);
            if(i > 2 && a[x][y] == 'W' && a[x - 1][y] == 'G' && a[x - 2][y] == 'R')
            {
                for(int j = 0; j < 3; j++)
                    for(int k = 0; k < 3; k++)
                        if(j != 2 && k != 2)
                            dp[i][j][1] = max(dp[i][j][1], dp[i - 1][k][j] + 1);
            }

            if(y > 2 && a[x][y] == 'W' && a[x][y - 1] == 'G' && a[x][y - 2] == 'R')
            {
                for(int j = 0; j < 3; j++)
                    for(int k = 0; k < 3; k++)
                        dp[i][j][2] = max(dp[i][j][2], dp[i - 1][k][j] + 1);
            }

            for(int j = 0; j < 3; j++)
                for(int k = 0; k < 3; k++)
                    mx = max(mx, dp[i][j][k]);
        }

        ans += mx;
    }

    printf("%d\n", ans);

    return 0;
}

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]
     scanf("%d%d\n", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~~~
dango_maker.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", a[i] + 1);
         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...