답안 #222950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222950 2020-04-14T11:59:21 Z Autoratch Dango Maker (JOI18_dango_maker) C++14
13 / 100
5 ms 640 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;
        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-3]);
        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-3][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 << dp[m][n];
}
# 결과 실행 시간 메모리 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 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 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 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Incorrect 5 ms 512 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Incorrect 5 ms 512 KB Output isn't correct
19 Halted 0 ms 0 KB -