Submission #223003

# Submission time Handle Problem Language Result Execution time Memory
223003 2020-04-14T13:18:20 Z Autoratch Dango Maker (JOI18_dango_maker) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 3001;

int m,n;
char c[N][N];
int v[N][N],h[N][N],vv[N][N],hh[N][N],dp[N][N],eh[N][N],ev[N][N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> m >> n;
    for(int i = 1;i <= m;i++) for(int j = 1;j <= n;j++) cin >> c[i][j];
    for(int i = 1;i <= m;i++) for(int j = 1;j <= n;j++) 
    {
        if(i>2 and c[i-2][j]=='R' and c[i-1][j]=='G' and c[i][j]=='W') v[i][j] = 1;
        if(j>2 and c[i][j-2]=='R' and c[i][j-1]=='G' and c[i][j]=='W') h[i][j] = 1;
        dp[i][j] = h[i][j]+v[i][j]+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
        if(v[i][j] and h[i][j]) dp[i][j]--;
        if(v[i][j-1] and h[i-1][j]) dp[i][j]--;
        if(i>1 and j>1 and v[i][j-2] and h[i-2][j]) dp[i][j]--;
        /*
        eh[i][j] = h[i][j],ev[i][j] = v[i][j];
        vv[i][j] = v[i][j]+vv[i-1][j];
        v[i][j]+=v[i][j-1];
        if(i>=3 and j>=3) v[i][j] = max(v[i][j],eh[i][j]+eh[i-1][j]+eh[i-2][j]+v[i][j-1]);
        hh[i][j] = h[i][j]+hh[i][j-1];
        h[i][j]+=h[i-1][j];
        if(i>=3 and j>=3) h[i][j] = max(h[i][j],ev[i][j]+ev[i][j-1]+ev[i][j-2]+h[i-1][j]);
        if(ev[i][j] and eh[i][j]) v[i][j]--,h[i][j]--;
        if(ev[i][j-1] and eh[i-1][j]) v[i][j]--,h[i][j]--;
        if(i>1 and j>1 and ev[i][j-2] and eh[i-2][j]) v[i][j]--,h[i][j]--;
        int ver = v[i][j],hor = h[i][j];
        if(i>=3) ver+=dp[i-3][j];
        if(j>=3) hor+=dp[i][j-3];
        ver = max(ver,vv[i][j]+dp[i][j-1]);
        hor = max(hor,hh[i][j]+dp[i-1][j]);
        dp[i][j] = max(ver,hor);
        
        cout << i << ' ' << j << endl;
        cout << v[i][j] << ' ' << vv[i][j] << ' ' << h[i][j] << ' ' << hh[i][j] << endl;
        cout << dp[i][j] << endl;
        */
    }
    cout << dp[m][n];
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Halted 0 ms 0 KB -