답안 #1064282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1064282 2024-08-18T11:10:46 Z oscar1f Dango Maker (JOI18_dango_maker) C++17
100 / 100
248 ms 18516 KB
#include<bits/stdc++.h>
using namespace std;

//#define int long long

const int TAILLE_MAX=3000+5;
int nbLig,nbCol,rep;
char val[TAILLE_MAX][TAILLE_MAX];
int memo[TAILLE_MAX][8];

int dyna(int lig,int col,int preced) {
    if (lig<0 or col>=nbCol) {
        return 0;
    }
    int ans=memo[lig][preced];
    if (ans!=-1) {
        return ans;
    }
    int coin=4*(preced%2);
    ans=dyna(lig-1,col+1,coin);
    if (preced/2==0 and val[lig][col]=='R' and val[lig+1][col]=='G' and val[lig+2][col]=='W') {
        ans++;
    }
    if (val[lig][col]=='R' and val[lig][col+1]=='G' and val[lig][col+2]=='W') {
        ans=max(ans,dyna(lig-1,col+1,coin+3)+1);
    }
    memo[lig][preced]=ans;
    return ans;
}

void calc(int lig,int col) {
    for (int i=0;i<nbLig;i++) {
        for (int j=0;j<8;j++) {
            memo[i][j]=-1;
        }
    }
    rep+=dyna(lig,col,0);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>nbLig>>nbCol;
    for (int i=0;i<nbLig;i++) {
        for (int j=0;j<nbCol;j++) {
            cin>>val[i][j];
        }
    }
    for (int i=0;i<nbLig;i++) {
        calc(i,0);
    }
    for (int j=1;j<nbCol;j++) {
        calc(nbLig-1,j);
    }
    cout<<rep<<endl;
    return 0;
}
 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 0 ms 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 460 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 456 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 428 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 356 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 0 ms 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 460 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 456 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 1 ms 344 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 7 ms 9308 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 4 ms 6236 KB Output is correct
58 Correct 23 ms 4440 KB Output is correct
59 Correct 208 ms 18260 KB Output is correct
60 Correct 210 ms 18364 KB Output is correct
61 Correct 212 ms 18448 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 194 ms 18068 KB Output is correct
64 Correct 242 ms 18444 KB Output is correct
65 Correct 245 ms 18516 KB Output is correct
66 Correct 248 ms 18260 KB Output is correct
67 Correct 147 ms 18260 KB Output is correct
68 Correct 149 ms 18424 KB Output is correct
69 Correct 152 ms 18260 KB Output is correct
70 Correct 26 ms 4484 KB Output is correct
71 Correct 26 ms 4444 KB Output is correct
72 Correct 26 ms 4512 KB Output is correct
73 Correct 26 ms 4444 KB Output is correct
74 Correct 27 ms 4444 KB Output is correct
75 Correct 27 ms 4336 KB Output is correct
76 Correct 26 ms 4308 KB Output is correct
77 Correct 27 ms 4504 KB Output is correct
78 Correct 26 ms 4440 KB Output is correct
79 Correct 27 ms 4444 KB Output is correct
80 Correct 27 ms 4444 KB Output is correct
81 Correct 26 ms 4504 KB Output is correct
82 Correct 27 ms 4444 KB Output is correct
83 Correct 27 ms 4512 KB Output is correct
84 Correct 27 ms 4500 KB Output is correct
85 Correct 26 ms 4440 KB Output is correct
86 Correct 26 ms 4444 KB Output is correct
87 Correct 26 ms 4440 KB Output is correct
88 Correct 34 ms 4444 KB Output is correct
89 Correct 26 ms 4444 KB Output is correct
90 Correct 27 ms 4444 KB Output is correct