Submission #591365

# Submission time Handle Problem Language Result Execution time Memory
591365 2022-07-07T10:46:38 Z ivaziva Dango Maker (JOI18_dango_maker) C++14
13 / 100
1 ms 368 KB
#include <bits/stdc++.h>

using namespace std;

#define MAXN 3010
#define MAXM 6020
#define INF 1000000007

bool moze[MAXM][MAXN][2];
char s[MAXN][MAXN];
long long dp [MAXN][2][2];

int main()
{
    long long n,m;
    cin>>n>>m;
    
    for (long long i=1;i<=n;i++)
    {
        for (long long j=1;j<=m;j++)
        {
            cin>>s[i][j];
        }
    }
    
    for (long long i=1;i<=n;i++)
    {
        for (long long j=1;j<=n;j++)
        {
            if (s[i][j]=='R' and s[i][j+1]=='G' and s[i][j+2]=='W') moze[i+j][i][0]=1;
            if (s[i][j]=='R' and s[i+1][j]=='G' and s[i+2][j]=='W') moze[i+j][i][1]=1;
        }
    }
    
    long long ans=0;
    
    for (long long z=2;z<=n+m;z++)
    {
        for (long long i=0;i<MAXN;i++) dp[i][0][0]=dp[i][0][1]=dp[i][1][0]=dp[i][1][1]=-INF;
        
        dp[0][0][0]=0;
        
        for (long long i=1;i<=n;i++)
        {
            for (int x=0;x<=1;x++)
            {
                for (int y=0;y<=1;y++)
                {
                    dp[i][0][x]=max(dp[i][0][x],dp[i-1][x][y]);
                    
                    if (moze[z][i][0] and x==0 and y==0)dp[i][0][x]=max(dp[i][0][x],dp[i-1][x][y]+1);
                    if (moze[z][i][1]) dp[i][1][x]=max(dp[i][1][x],dp[i-1][x][y]+1);
                }
            }
        }
        
        long long tmp=0;
        
        for (int x=0;x<2;x++)
        {
            for (int y=0;y<2;y++)
            {
                tmp=max(tmp,dp[n][x][y]);
            }
        }
        
        ans+=tmp;
    }
    
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 368 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 1 ms 368 KB Output isn't correct
20 Halted 0 ms 0 KB -