QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769792#9463. 基础 ABC 练习题miaomiaomiaowu40 1ms3836kbC++985.4kb2024-11-21 19:24:562024-11-21 19:24:57

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 19:24:57]
  • 评测
  • 测评结果:40
  • 用时:1ms
  • 内存:3836kb
  • [2024-11-21 19:24:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=185;
char a[N],s1[N],s2[N];
int T,cas,n,nxta[N],nxtb[N];
unsigned dp[4][61][61],qwq[4][61][61];
int main(){
    // freopen("qwq.in","r",stdin);
    // freopen("qwq.out","w",stdout);
    int B=58;
    for(cin>>T>>cas;T;T--){
        scanf("%d%s%s%s",&n,s1,s2,a+1);
        if(cas<=2){
            int n1=0,n2=0,n3=0,ca=0,cb=0,cc=0;
            for(int i=1;i<=3*n;i++){
                if(a[i]=='A')n1++,n2--;
                if(a[i]=='B')n2++,n3--;
                if(a[i]=='C')n3++,n1--;
                ca=max(ca,n1);
                cb=max(cb,n2);
                cc=max(cc,n3);
            }
            if(ca+cb+cc>n){
                puts("0");continue;
            }
            bool flag=0;
            for(int i=ca;i+cb+cc<=n;i++)if(s1[i]=='1'){
                for(int j=cb;i+j+cc<=n;j++){
                    if(s2[j]=='1')flag=1;
                }
            }
            puts(flag?"1":"0");
        }
        else{
            if(n!=B){
                puts("-1");continue;
            }
            nxta[n+1]=n+1,nxtb[n+1]=n+1;
            for(int i=n;i>=0;i--){
                if(s1[i]=='1')nxta[i]=i;
                else nxta[i]=nxta[i+1];
                if(s2[i]=='1')nxtb[i]=i;
                else nxtb[i]=nxtb[i+1];
            }
            unsigned ans=0;
            for(int la=0;la<=n;la++){
                for(int lb=0;la+lb<=n;lb++){
                    int lc=n-nxta[la]-nxtb[lb];
                    if(lc<0)continue;
                    memset(dp,0,sizeof dp);
                    dp[(la==0)+(la==0)+(lb==0)][0][0]=1;
                    for(int i=1;i<=3*n;i++){
                        memcpy(qwq,dp,sizeof qwq);
                        memset(dp,0,sizeof dp);
                        if(a[i]=='A'){
                            for(register int j=0;j<i&&j<n;++j)for(register int k=0,w=i-1-j;k<i&&k<=n;++k,--w){
                                if(j+1-w<=la){
                                    if(qwq[0][j][k])dp[(j+1-w==la)<<1][j+1][k]+=qwq[0][j][k];
                                    if(qwq[1][j][k])dp[(j+1-w==la)<<1|1][j+1][k]+=qwq[1][j][k];
                                    if(qwq[2][j][k])dp[2][j+1][k]+=qwq[2][j][k];
                                    if(qwq[3][j][k])dp[3][j+1][k]+=qwq[3][j][k];
                                }
                            }
                        }
                        else if(a[i]=='B'){
                            for(register int j=0;j<i&&j<=n;++j)for(register int k=0,w=i-1-j;k<i&&k<n;++k,--w){
                                if(k+1-j<=lb){
                                    if(qwq[0][j][k])dp[k+1-j==lb][j][k+1]+=qwq[0][j][k];
                                    if(qwq[1][j][k])dp[1][j][k+1]+=qwq[1][j][k];
                                    if(qwq[2][j][k])dp[2^(k+1-j==lb)][j][k+1]+=qwq[2][j][k];
                                    if(qwq[3][j][k])dp[3][j][k+1]+=qwq[3][j][k];
                                }
                            }
                        }
                        else if(a[i]=='C'){
                            for(register int j=0;j<i&&j<=n;++j)for(register int k=0,w=i-1-j;k<i&&k<=n;++k,--w){
                                if(w<n&&w+1-k<=lc){
                                    if(qwq[0][j][k])dp[0][j][k]+=qwq[0][j][k];
                                    if(qwq[1][j][k])dp[1][j][k]+=qwq[1][j][k];
                                    if(qwq[2][j][k])dp[2][j][k]+=qwq[2][j][k];
                                    if(qwq[3][j][k])dp[3][j][k]+=qwq[3][j][k];
                                }
                            }
                        }
                        else{
                            for(register int j=0;j<i&&j<=n;++j)for(register int k=0,w=i-1-j;k<i&&k<=n;++k,--w){
                                if(qwq[0][j][k]){
                                    if(j<n&&j+1-w<=la)dp[(j+1-w==la)<<1][j+1][k]+=qwq[0][j][k];
                                    if(k<n&&k+1-j<=lb)dp[k+1-j==lb][j][k+1]+=qwq[0][j][k];
                                    if(w<n&&w+1-k<=lc)dp[0][j][k]+=qwq[0][j][k];
                                }
                                if(qwq[1][j][k]){
                                    if(j<n&&j+1-w<=la)dp[(j+1-w==la)<<1|1][j+1][k]+=qwq[1][j][k];
                                    if(k<n&&k+1-j<=lb)dp[1][j][k+1]+=qwq[1][j][k];
                                    if(w<n&&w+1-k<=lc)dp[1][j][k]+=qwq[1][j][k];
                                }
                                if(qwq[2][j][k]){
                                    if(j<n&&j+1-w<=la)dp[2][j+1][k]+=qwq[2][j][k];
                                    if(k<n&&k+1-j<=lb)dp[2^(k+1-j==lb)][j][k+1]+=qwq[2][j][k];
                                    if(w<n&&w+1-k<=lc)dp[2][j][k]+=qwq[2][j][k];
                                }
                                if(qwq[3][j][k]){
                                    if(j<n&&j+1-w<=la)dp[3][j+1][k]+=qwq[3][j][k];
                                    if(k<n&&k+1-j<=lb)dp[3][j][k+1]+=qwq[3][j][k];
                                    if(w<n&&w+1-k<=lc)dp[3][j][k]+=qwq[3][j][k];
                                }
                            }
                        }
                    }
                    ans+=dp[3][n][n];
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 3836kb

input:

60 1
1
11
11
ABC
2
111
111
CABABC
3
1111
1111
CAABBCBAC
4
11111
11111
BACBBACBACAC
5
111111
111111
CABCCBBAABCCBAA
6
1111111
1111111
ABABABCACBCBCCACBA
7
11111111
11111111
BCAABACBBCBBABCCAACAC
8
111111111
111111111
CCBCBBBCAABCBCAAAAACBCBA
9
1111111111
1111111111
CCCCACABCBABAABCCAABABBCBBA
10
1111...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #2:

score: 20
Accepted
time: 0ms
memory: 3724kb

input:

60 1
1
11
11
CBA
2
111
111
BACACB
3
1111
1111
BCBCACABA
4
11111
11111
CCBACABBBCAA
5
111111
111111
BCACBBABBCCAACA
6
1111111
1111111
BBCBACCAACBCBCAABA
7
11111111
11111111
ACBCCBBAABAABCACCACBB
8
111111111
111111111
BAACACBACCCBAACCBABABBCB
9
1111111111
1111111111
BABCBCAAAAABBCCCACBCBBABACC
10
1111...

output:

0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #3:

score: 20
Accepted
time: 1ms
memory: 3836kb

input:

60 1
1
11
11
BCA
2
111
111
BCABCA
3
1111
1111
CBACCAABB
4
11111
11111
BACBCBBCCAAA
5
111111
111111
BCCCBABACCBABAA
6
1111111
1111111
ACAACBABABBCACBCCB
7
11111111
11111111
BBBCABCCCAABCACBACAAB
8
111111111
111111111
ACCACAABACBAABBCBCBBACBC
9
1111111111
1111111111
BCCBACBBACCCBCCAABAACABAABB
10
1111...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #4:

score: 20
Accepted
time: 0ms
memory: 3728kb

input:

60 1
1
11
11
BCA
2
111
111
ACABCB
3
1111
1111
BABCABCCA
4
11111
11111
CCABACABBACB
5
111111
111111
ABBBCBBCACCAACA
6
1111111
1111111
CACBABCABCCBABAACB
7
11111111
11111111
BACBCABACBBCCCBAAACAB
8
111111111
111111111
CABABBCAACABCBACBABACBCC
9
1111111111
1111111111
BCBAACBABABCBACBABABCCACACC
10
1111...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #5:

score: 20
Accepted
time: 1ms
memory: 3708kb

input:

60 1
1
11
11
ABC
2
111
111
BBCACA
3
1111
1111
ACBBCBAAC
4
11111
11111
ABACACCCABBB
5
111111
111111
ACCCCCAAABABBBB
6
1111111
1111111
ABAABBBBCCCCCCAABA
7
11111111
11111111
ACBBBACCCCCCAABABBBAA
8
111111111
111111111
CAAABAAACCCCBBCBBBCACBAB
9
1111111111
1111111111
ABAAACBBCCCCCCCBAAABAACBBBB
10
1111...

output:

1
1
0
0
0
1
1
0
1
1
1
1
1
0
1
1
1
0
0
0
0
1
1
1
0
1
1
1
1
1
0
0
1
0
1
0
1
0
0
0
1
0
0
0
1
1
0
1
0
0
1
0
1
0
1
0
0
0
1
0

result:

ok Accepted!!!

Test #6:

score: 20
Accepted
time: 0ms
memory: 3780kb

input:

60 1
1
11
11
BCA
2
111
111
ACCBAB
3
1111
1111
BACCACBBA
4
11111
11111
AAABBCBCBACC
5
111111
111111
AABBBBCCBCCAACA
6
1111111
1111111
AAACCBCCCAABACBBBB
7
11111111
11111111
AAACACCACBBAABBCBCCBB
8
111111111
111111111
AAACAAABBBBBBBCBACCCACCC
9
1111111111
1111111111
BBCCACCCACCACCBAABBAAAABBBB
10
1111...

output:

1
0
0
1
1
0
1
1
1
1
1
0
0
0
1
1
1
0
0
1
0
1
1
1
1
1
1
0
1
1
1
1
1
0
0
0
0
0
1
1
0
1
0
1
0
0
1
0
0
1
0
1
0
1
0
1
1
1
0
1

result:

ok Accepted!!!

Test #7:

score: 20
Accepted
time: 0ms
memory: 3728kb

input:

60 1
1
11
11
BCA
2
111
111
ACCABB
3
1111
1111
CAABBBCAC
4
11111
11111
BBCCBCCABAAA
5
111111
111111
BAABBBCCCCCAABA
6
1111111
1111111
AACACCCCBABBBCAABB
7
11111111
11111111
AACBBCBBBCCCCCAAABBAA
8
111111111
111111111
AAAABBCBBBBCBBCCCCCCAAAA
9
1111111111
1111111111
ABBBBBBBBCCBCAACCACAACCAAAC
10
1111...

output:

1
0
1
1
1
0
1
1
1
1
0
1
1
0
1
1
0
0
1
0
1
1
0
1
1
0
0
0
0
1
1
0
0
1
0
1
1
1
0
0
1
0
1
1
1
1
1
0
0
1
1
0
0
0
0
0
1
0
1
1

result:

ok Accepted!!!

Test #8:

score: 20
Accepted
time: 0ms
memory: 3724kb

input:

60 1
1
11
11
ABC
2
111
111
AABCBC
3
1111
1111
ABAACBBCC
4
11111
11111
AABCCBBBCACA
5
111111
111111
AAACCABBBACBCCB
6
1111111
1111111
AABBBBBBCCACAACACC
7
11111111
11111111
AAAABBBBBBCCACCCCCBAA
8
111111111
111111111
ACCBABBABBBBBCCCACCCAAAA
9
1111111111
1111111111
BAAAABCCCCCCCBBAABAACABCBBB
10
1111...

output:

1
1
1
0
1
1
1
1
0
1
0
1
1
1
0
1
1
1
0
0
0
0
1
0
1
0
0
1
1
0
0
1
0
0
0
1
1
0
1
1
1
0
1
0
0
0
0
1
1
0
0
1
0
1
1
1
0
1
1
0

result:

ok Accepted!!!

Test #9:

score: 20
Accepted
time: 0ms
memory: 3644kb

input:

60 1
1
11
11
CAB
2
111
111
CCAABB
3
1111
1111
ACCCABBAB
4
11111
11111
AAABBBBCCACC
5
111111
111111
BCACCCCBAAAABBB
6
1111111
1111111
CAAACABABACCCBCBBB
7
11111111
11111111
ACAAACBCCCCBCAABBABBB
8
111111111
111111111
ACCAACACCCCCABABAABBBBBB
9
1111111111
1111111111
AACAAAAAACBCCBCBACBBBBBBCCC
10
1111...

output:

1
1
0
1
1
0
0
0
0
1
1
0
0
1
1
0
1
1
1
1
0
0
1
0
1
1
0
1
1
1
1
0
0
0
0
1
0
0
1
0
1
0
1
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
1
1

result:

ok Accepted!!!

Test #10:

score: 20
Accepted
time: 1ms
memory: 3828kb

input:

60 1
1
11
11
BCA
2
111
111
ACACBB
3
1111
1111
AABCCCABB
4
11111
11111
CBCCCABABABA
5
111111
111111
ACACCCAABBCBABB
6
1111111
1111111
BACAAAACCBABCBCBCB
7
11111111
11111111
AAAAABBBBCCBBCCCCACAB
8
111111111
111111111
AACCCCCCABAAACAABCBBBBBB
9
1111111111
1111111111
AABAAAABCCCCABCCCABBCCABBBB
10
1111...

output:

1
0
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
0
1
1
0
1
1
0
1
1
0
1
1
0
0
1
0
1
0
1
0
1
1
0
0
1
0
0
0
0
1
1
1
0
0
0
0
1
0
1
1
0
1
1

result:

ok Accepted!!!

Test #11:

score: 20
Accepted
time: 0ms
memory: 3832kb

input:

60 1
1
11
11
BCA
2
111
111
CBBCAA
3
1111
1111
AABABCCCB
4
11111
11111
BABCBBCAAACC
5
111111
111111
AAACBBBBBCAACCC
6
1111111
1111111
BBBBBCCCCCCAABAAAA
7
11111111
11111111
BAAAABAACCCABBCCBBBCC
8
111111111
111111111
ABABBBBBCBCCCACCCCAAABAA
9
1111111111
1111111111
AAAABBAABCABACCCACCCBBCBCBB
10
1111...

output:

1
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
1
0
1
0
0
0
1
1
1
1
0
1
1
0
1
0
0
0
0
1
0
1
0
0
1
1
1
1
1
1
0
1
0
1
1
1
0
1
1
1
1
1
1
1

result:

ok Accepted!!!

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #12:

score: 20
Accepted
time: 0ms
memory: 3724kb

input:

60 2
1
01
11
ABC
2
101
001
ACBABC
3
0011
1000
AAACBBCBC
4
11100
00100
BACABCABACBC
5
001101
110010
ACBABCCABBCCAAB
6
0101010
1000011
CABBAAACACBBCCABCB
7
10010111
10100111
CABAAACBBAACBCACBBBCC
8
100101000
100000110
BACBCACBBAABCCCABCBAACBA
9
1100010100
0111110011
CAABCBBABCACBCACABCABAACBBC
10
0001...

output:

1
0
0
1
1
0
1
0
1
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #13:

score: 20
Accepted
time: 1ms
memory: 3828kb

input:

60 2
1
01
01
CAB
2
011
101
ABCCBA
3
1111
0000
CBBAACCBA
4
00011
10011
BCCBCCABABAA
5
011111
111011
ACBBABCBCCAACBA
6
1011101
1101000
CBABBCACBAABABCACC
7
00001111
11010100
BCACAABCBBBCCABABCACA
8
110110100
010010100
ABAABCABCABAACCCCBBBBCCA
9
0000111111
1011100011
BAAABBCCABBBBCABACBACACCACC
10
0011...

output:

0
0
0
0
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #14:

score: 20
Accepted
time: 0ms
memory: 3780kb

input:

60 2
1
01
00
ABC
2
111
000
CAABBC
3
0101
0011
CAACBCBAB
4
11011
01001
CABBCAACBBCA
5
000010
010100
BCCCACAAACBBBBA
6
0011011
0011000
BCACCBAAAAABCBCBBC
7
11000001
11111111
AACBCABACCBBCABCCBAAB
8
111010100
111101010
CBABCACBABAACBABCCCBCAAB
9
1001111111
1011000111
CAABCACCABBBABBCACCABBCAACB
10
0011...

output:

0
0
0
1
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #15:

score: 20
Accepted
time: 0ms
memory: 3784kb

input:

60 2
1
00
10
BCA
2
110
000
BCAABC
3
0111
1001
CACAABBBC
4
10101
00000
ACCBCAABBACB
5
010001
100001
BBCBBAACCBACACA
6
0100101
0100010
CCAAAABCCAABBCBBBC
7
10010000
10010011
BCBCACBCBAAAABCABBCCA
8
001101111
110010111
CABACABCACBBABCBCABACABC
9
1000111100
1011101001
ACBCABABBCCBABCCAAACBBBACAC
10
1111...

output:

0
0
1
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #16:

score: 20
Accepted
time: 0ms
memory: 3772kb

input:

60 2
1
10
11
CAB
2
110
100
AABBCC
3
0100
0110
CAABCBABC
4
01010
01000
BCBCABACBCAA
5
001110
100000
AAABBCCCABCBABC
6
1000000
1101100
ACCBACBCAABCAABBCB
7
11011110
01000000
AAAAABABBBCBBBACCCCCC
8
101000000
010000000
ACBABBCCCCCCCABAAABAABBB
9
1000000000
1000000000
CCCCCCCCCAABAAABABBBABBAABB
10
0111...

output:

1
0
1
0
1
0
1
1
1
1
1
1
1
1
0
0
1
0
1
1
1
1
1
0
1
1
1
0
0
1
1
1
1
0
1
0
1
1
1
1
0
1
1
0
0
1
1
0
1
1
1
0
0
1
1
1
1
1
1
1

result:

ok Accepted!!!

Test #17:

score: 20
Accepted
time: 0ms
memory: 3704kb

input:

60 2
1
01
10
ABC
2
100
100
BCABCA
3
1000
1100
CABACCBAB
4
11001
10000
AABCBACABBCC
5
110000
101110
BACBCAABCABCBCA
6
1110000
1111100
AABBBBCABCCCCABAAC
7
10110000
11100000
AAACCABBCAABCBBABBCCC
8
001111100
011000000
ABAACAAAACABCBCBBBBBCCCC
9
0110000000
1111000000
AACBBACBBBCBCABACACBCAABCCA
10
1111...

output:

1
0
0
1
1
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
0
0
0
1
1
1
1
1
0
1
0
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
0
0
1
1
1
0
1
1
1
0
0
0

result:

ok Accepted!!!

Test #18:

score: 20
Accepted
time: 0ms
memory: 3836kb

input:

60 2
1
10
11
ABC
2
100
100
CABCAB
3
1000
1000
CCABCABAB
4
11100
10000
ACACBABCABCB
5
111101
100000
AABCABCBACABBCC
6
1000000
0100000
BCACCCCCABAAABBBBA
7
10101110
11000000
AAABBCBBCACCCABBAACBC
8
111110000
001100000
ACBBCBBCABACCACBBABAACCA
9
1110000000
1111110000
CAAACBCCBBAAABCCBACABACCBBB
10
1100...

output:

0
1
1
1
1
1
1
1
1
0
0
1
1
0
1
0
0
1
0
1
0
0
0
1
1
0
1
1
0
0
0
1
1
1
1
1
1
0
1
1
1
0
1
0
1
1
1
1
0
0
1
1
1
1
1
0
0
1
0
1

result:

ok Accepted!!!

Test #19:

score: 20
Accepted
time: 0ms
memory: 3768kb

input:

60 2
1
11
10
ABC
2
100
110
BCABCA
3
1000
1111
BBCBACCAA
4
10000
10011
BCABCABCABCA
5
011111
100000
AABCBCABACABCBC
6
1110000
1000000
CAAACCCBBBCAACABBB
7
10000000
01000000
ABBCACCCABBACABACBBAC
8
110100011
100000000
AABBCABCCAABBCABCABCABCC
9
1111011100
1100000000
AAACABBBBBCACABCCBABCACBCCA
10
0111...

output:

1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
0
1
1
0
0
1
1
1
1
0
0
1
0
1
1
0
1
1
1
0
0
1
1
1
1
0
1
0
0
1

result:

ok Accepted!!!

Test #20:

score: 20
Accepted
time: 0ms
memory: 3652kb

input:

60 2
1
10
10
CAB
2
110
100
ABCACB
3
1000
1000
CABCABCAB
4
10111
10000
CABCABCABCAB
5
100000
110000
BCCAABCBCABACAB
6
1000000
1111000
CCCABACAABBCABCABB
7
10000000
11000110
BBCBBBCCACCCBABAAACAA
8
110000000
100000000
AACBCABCABBACCABCBCAABBC
9
1000000000
1100000000
BBCCACACCCBBACBCCABABAAAABB
10
1111...

output:

1
1
1
1
1
1
1
0
0
1
1
0
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
1
1
0
1
1
1
0
1
0
1
1
1
0
1
1
0

result:

ok Accepted!!!

Test #21:

score: 20
Accepted
time: 0ms
memory: 3836kb

input:

60 2
1
10
10
CAB
2
110
100
CABCAB
3
0111
1000
CABCABCAB
4
11010
11000
AAABBBCBACCC
5
110000
100000
ACBACABCBABCABC
6
1111000
1111000
AAABBBBBCACCCAABCC
7
11011100
01000000
AAAAACCBCBCBBBCACACBB
8
111000000
111010000
AAABBBBBCCCCCCCABACABABA
9
1011100010
1000000000
AAABAABAABBABBCCCCBCCCCBACB
10
1111...

output:

1
1
1
1
1
1
0
0
1
0
1
0
1
1
1
1
0
1
1
1
0
0
1
1
1
1
0
0
1
1
0
1
0
0
1
1
0
1
1
0
0
1
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
0
0
1

result:

ok Accepted!!!

Subtask #3:

score: 0
Time Limit Exceeded

Test #22:

score: 0
Time Limit Exceeded

input:

60 3
1
11
11
???
2
111
111
??????
3
1111
1111
?????????
4
11111
11111
????????????
5
111111
111111
???????????????
6
1111111
1111111
??????????????????
7
11111111
11111111
?????????????????????
8
111111111
111111111
????????????????????????
9
1111111111
1111111111
???????????????????????????
10
1111...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%