답안 #123046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123046 2019-06-30T05:54:39 Z arnold518 Dango Maker (JOI18_dango_maker) C++14
33 / 100
2000 ms 94392 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 10;
const int MAXVAL = 6e4;

int N, M;
char A[MAXN+10][MAXN+10];

int pow3[MAXN+10], dp[MAXN+10][MAXN+10][MAXVAL+10];

int solve(int y, int x, int mask)
{
    if(y==N) return 0;

    int &ret=dp[y][x][mask];
    if(ret!=-1) return ret;
    ret=0;

    if(x+1==M) ret=max(ret, solve(y+1, 0, mask/3+pow3[M-1]*(max(mask%3-1, 0))));
    else ret=max(ret, solve(y, x+1, mask/3+pow3[M-1]*(max(mask%3-1, 0))));

    if(A[y][x]=='R')
    {
        if(y+2<N && A[y][x]=='R' && A[y+1][x]=='G' && A[y+2][x]=='W' && mask%3==0)
        {
            if(x+1==M) ret=max(ret, solve(y+1, 0, mask/3+pow3[M-1]*2)+1);
            else ret=max(ret, solve(y, x+1, mask/3+pow3[M-1]*2)+1);
        }
        if(x+2<M && A[y][x]=='R' && A[y][x+1]=='G' && A[y][x+2]=='W' && mask%27==0)
        {
            if(x+3==M) ret=max(ret, solve(y+1, 0, mask/27)+1);
            else ret=max(ret, solve(y, x+3, mask/27)+1);
        }
    }
    return ret;
}

int main()
{
    int i, j;

    scanf("%d%d", &N, &M);
    for(i=0; i<N; i++) scanf("%s", A[i]);

    pow3[0]=1;
    for(i=1; i<=MAXN; i++) pow3[i]=pow3[i-1]*3;
    memset(dp, -1, sizeof(dp));

    printf("%d", solve(0, 0, 0));
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:45:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
dango_maker.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:48:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0; i<N; i++) scanf("%s", A[i]);
                        ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 94328 KB Output is correct
2 Correct 78 ms 94328 KB Output is correct
3 Correct 78 ms 94328 KB Output is correct
4 Correct 77 ms 94200 KB Output is correct
5 Correct 77 ms 94200 KB Output is correct
6 Correct 77 ms 94328 KB Output is correct
7 Correct 77 ms 94328 KB Output is correct
8 Correct 78 ms 94328 KB Output is correct
9 Correct 77 ms 94328 KB Output is correct
10 Correct 77 ms 94328 KB Output is correct
11 Correct 76 ms 94328 KB Output is correct
12 Correct 77 ms 94328 KB Output is correct
13 Correct 76 ms 94200 KB Output is correct
14 Correct 77 ms 94328 KB Output is correct
15 Correct 78 ms 94200 KB Output is correct
16 Correct 78 ms 94328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 94328 KB Output is correct
2 Correct 78 ms 94328 KB Output is correct
3 Correct 78 ms 94328 KB Output is correct
4 Correct 77 ms 94200 KB Output is correct
5 Correct 77 ms 94200 KB Output is correct
6 Correct 77 ms 94328 KB Output is correct
7 Correct 77 ms 94328 KB Output is correct
8 Correct 78 ms 94328 KB Output is correct
9 Correct 77 ms 94328 KB Output is correct
10 Correct 77 ms 94328 KB Output is correct
11 Correct 76 ms 94328 KB Output is correct
12 Correct 77 ms 94328 KB Output is correct
13 Correct 76 ms 94200 KB Output is correct
14 Correct 77 ms 94328 KB Output is correct
15 Correct 78 ms 94200 KB Output is correct
16 Correct 78 ms 94328 KB Output is correct
17 Correct 77 ms 94200 KB Output is correct
18 Correct 77 ms 94220 KB Output is correct
19 Correct 78 ms 94300 KB Output is correct
20 Correct 77 ms 94244 KB Output is correct
21 Correct 78 ms 94300 KB Output is correct
22 Correct 78 ms 94244 KB Output is correct
23 Correct 79 ms 94240 KB Output is correct
24 Correct 79 ms 94200 KB Output is correct
25 Correct 93 ms 94320 KB Output is correct
26 Correct 92 ms 94328 KB Output is correct
27 Correct 82 ms 94328 KB Output is correct
28 Correct 83 ms 94348 KB Output is correct
29 Correct 91 ms 94328 KB Output is correct
30 Correct 80 ms 94328 KB Output is correct
31 Correct 80 ms 94340 KB Output is correct
32 Correct 78 ms 94200 KB Output is correct
33 Correct 79 ms 94328 KB Output is correct
34 Correct 79 ms 94328 KB Output is correct
35 Correct 78 ms 94328 KB Output is correct
36 Correct 79 ms 94392 KB Output is correct
37 Correct 79 ms 94332 KB Output is correct
38 Correct 78 ms 94200 KB Output is correct
39 Correct 78 ms 94328 KB Output is correct
40 Correct 78 ms 94200 KB Output is correct
41 Correct 79 ms 94328 KB Output is correct
42 Correct 91 ms 94200 KB Output is correct
43 Correct 93 ms 94200 KB Output is correct
44 Correct 79 ms 94328 KB Output is correct
45 Correct 85 ms 94328 KB Output is correct
46 Correct 79 ms 94316 KB Output is correct
47 Correct 79 ms 94228 KB Output is correct
48 Correct 78 ms 94200 KB Output is correct
49 Correct 78 ms 94328 KB Output is correct
50 Correct 78 ms 94312 KB Output is correct
51 Correct 78 ms 94332 KB Output is correct
52 Correct 79 ms 94200 KB Output is correct
53 Correct 79 ms 94328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 94328 KB Output is correct
2 Correct 78 ms 94328 KB Output is correct
3 Correct 78 ms 94328 KB Output is correct
4 Correct 77 ms 94200 KB Output is correct
5 Correct 77 ms 94200 KB Output is correct
6 Correct 77 ms 94328 KB Output is correct
7 Correct 77 ms 94328 KB Output is correct
8 Correct 78 ms 94328 KB Output is correct
9 Correct 77 ms 94328 KB Output is correct
10 Correct 77 ms 94328 KB Output is correct
11 Correct 76 ms 94328 KB Output is correct
12 Correct 77 ms 94328 KB Output is correct
13 Correct 76 ms 94200 KB Output is correct
14 Correct 77 ms 94328 KB Output is correct
15 Correct 78 ms 94200 KB Output is correct
16 Correct 78 ms 94328 KB Output is correct
17 Correct 77 ms 94200 KB Output is correct
18 Correct 77 ms 94220 KB Output is correct
19 Correct 78 ms 94300 KB Output is correct
20 Correct 77 ms 94244 KB Output is correct
21 Correct 78 ms 94300 KB Output is correct
22 Correct 78 ms 94244 KB Output is correct
23 Correct 79 ms 94240 KB Output is correct
24 Correct 79 ms 94200 KB Output is correct
25 Correct 93 ms 94320 KB Output is correct
26 Correct 92 ms 94328 KB Output is correct
27 Correct 82 ms 94328 KB Output is correct
28 Correct 83 ms 94348 KB Output is correct
29 Correct 91 ms 94328 KB Output is correct
30 Correct 80 ms 94328 KB Output is correct
31 Correct 80 ms 94340 KB Output is correct
32 Correct 78 ms 94200 KB Output is correct
33 Correct 79 ms 94328 KB Output is correct
34 Correct 79 ms 94328 KB Output is correct
35 Correct 78 ms 94328 KB Output is correct
36 Correct 79 ms 94392 KB Output is correct
37 Correct 79 ms 94332 KB Output is correct
38 Correct 78 ms 94200 KB Output is correct
39 Correct 78 ms 94328 KB Output is correct
40 Correct 78 ms 94200 KB Output is correct
41 Correct 79 ms 94328 KB Output is correct
42 Correct 91 ms 94200 KB Output is correct
43 Correct 93 ms 94200 KB Output is correct
44 Correct 79 ms 94328 KB Output is correct
45 Correct 85 ms 94328 KB Output is correct
46 Correct 79 ms 94316 KB Output is correct
47 Correct 79 ms 94228 KB Output is correct
48 Correct 78 ms 94200 KB Output is correct
49 Correct 78 ms 94328 KB Output is correct
50 Correct 78 ms 94312 KB Output is correct
51 Correct 78 ms 94332 KB Output is correct
52 Correct 79 ms 94200 KB Output is correct
53 Correct 79 ms 94328 KB Output is correct
54 Execution timed out 2059 ms 256 KB Time limit exceeded
55 Halted 0 ms 0 KB -