답안 #233923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233923 2020-05-22T12:20:06 Z nicolaalexandra Dango Maker (JOI18_dango_maker) C++14
100 / 100
538 ms 88568 KB
#include <bits/stdc++.h>
#define DIM 3001
using namespace std;

int dp[DIM][DIM][2];
char a[DIM][DIM];
int n,m,i,j;

int verif_vert (int i, int j){
    if (a[i-2][j] == 'R' && a[i-1][j] == 'G' && a[i][j] == 'W')
        return 1;
    return 0;
}
int verif_oriz (int i, int j){
    if (a[i][j-2] == 'R' && a[i][j-1] == 'G' && a[i][j] == 'W')
        return 1;
    return 0;
}
int main (){

   // ifstream cin ("date.in");
   // ofstream cout ("date.out");

    cin>>n>>m;
    for (i=1;i<=n;i++)
        cin>>a[i]+1;

    /**
        R G W
      R G W
    R G W

    **/

    /// dp[i][j][0/1] - nr maxim de piese pe care le pot lua pana la i,j
    /// 0 - orizontal, 1 - vertical

    for (i=1;i<=n;i++)
        for (j=1;j<=m;j++){
            /// nu fac nimic
            dp[i][j][0] = max (dp[i-1][j+1][0],dp[i-1][j+1][1]);
            dp[i][j][1] = max (dp[i-1][j+1][0],dp[i-1][j+1][1]);

            /// incerc sa pun piese orizontala sau verticala
            if (verif_oriz(i,j+1))
                dp[i][j][0] = max (dp[i][j][0],dp[i-1][j+1][0] + 1);
            if (verif_vert(i+1,j))
                dp[i][j][1] = max (dp[i][j][1],dp[i-1][j+1][1] + 1);
        }

    int sol = 0;
    for (i=1;i<=n;i++)
        sol += max(dp[i][1][0],dp[i][1][1]);

    for (i=2;i<=m;i++)
        sol += max (dp[n][i][0],dp[n][i][1]);

    cout<<sol;

    return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:26:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         cin>>a[i]+1;
              ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 436 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 436 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 4 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 436 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 256 KB Output is correct
14 Correct 4 ms 256 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 4 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 5 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 5 ms 384 KB Output is correct
52 Correct 4 ms 384 KB Output is correct
53 Correct 4 ms 384 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 14 ms 21248 KB Output is correct
56 Correct 5 ms 512 KB Output is correct
57 Correct 12 ms 14464 KB Output is correct
58 Correct 66 ms 16120 KB Output is correct
59 Correct 538 ms 88376 KB Output is correct
60 Correct 538 ms 88464 KB Output is correct
61 Correct 534 ms 88440 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 522 ms 88188 KB Output is correct
64 Correct 462 ms 88568 KB Output is correct
65 Correct 480 ms 88440 KB Output is correct
66 Correct 472 ms 88440 KB Output is correct
67 Correct 457 ms 88568 KB Output is correct
68 Correct 453 ms 88440 KB Output is correct
69 Correct 458 ms 88440 KB Output is correct
70 Correct 57 ms 16120 KB Output is correct
71 Correct 57 ms 16124 KB Output is correct
72 Correct 57 ms 16120 KB Output is correct
73 Correct 58 ms 16120 KB Output is correct
74 Correct 57 ms 16120 KB Output is correct
75 Correct 58 ms 16120 KB Output is correct
76 Correct 57 ms 16120 KB Output is correct
77 Correct 56 ms 16120 KB Output is correct
78 Correct 57 ms 16120 KB Output is correct
79 Correct 58 ms 16120 KB Output is correct
80 Correct 57 ms 16120 KB Output is correct
81 Correct 58 ms 16120 KB Output is correct
82 Correct 57 ms 16120 KB Output is correct
83 Correct 57 ms 16120 KB Output is correct
84 Correct 58 ms 16120 KB Output is correct
85 Correct 58 ms 16120 KB Output is correct
86 Correct 57 ms 16120 KB Output is correct
87 Correct 57 ms 16120 KB Output is correct
88 Correct 57 ms 16120 KB Output is correct
89 Correct 56 ms 16120 KB Output is correct
90 Correct 57 ms 16120 KB Output is correct