QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687602#9463. 基础 ABC 练习题HuTao0 2216ms7672kbC++142.4kb2024-10-29 19:56:052024-10-29 19:56:06

Judging History

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

  • [2024-10-29 19:56:06]
  • 评测
  • 测评结果:0
  • 用时:2216ms
  • 内存:7672kb
  • [2024-10-29 19:56:05]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 62;

int n;
char s0[N], s1[N];
char s[N * 3];
unsigned f[N][N][N][2][2];

inline void Work()
{
    scanf("%d%s%s%s", &n, s0, s1, s + 1);
    if(n != 60) return void(puts("-1"));
    for(int i = 0; i <= n; i ++ ) s0[i] ^= 48, s1[i] ^= 48;
    unsigned ans = 0;
    for(int x = 0; x <= n; x ++ )
        for(int y = 0; y <= n - x; y ++ )
        {
            if(!s0[x] || !s1[y]) continue;
            int z = n - x - y;
            memset(f, 0, sizeof f);
            f[0][0][0][!x][!y] = 1;
            int p = x - 1, q = y - 1;
            while(p >= 0 && !s0[p]) p -- ;
            while(q >= 0 && !s1[q]) q -- ;
            for(int i = 0; i <= n; i ++ )
                for(int j = 0; j <= n; j ++ )
                    for(int k = 0; k <= n; k ++ )
                    {
                        if(!f[i][j][k][0][0] && !f[i][j][k][0][1] && !f[i][j][k][1][0] && !f[i][j][k][1][1]) continue;
                        #define Get(r, s, t) \
                            (r - t <= x && s - r <= y && t - s <= z) && ( \
                                f[r][s][t][r - t > p][s - r > q] += f[i][j][k][0][0],\
                                f[r][s][t][r - t > p][    1    ] += f[i][j][k][0][1],\
                                f[r][s][t][    1    ][s - r > q] += f[i][j][k][1][0],\
                                f[r][s][t][    1    ][    1    ] += f[i][j][k][1][1] \
                            )
                        switch (s[i + j + k + 1])
                        {
                            case 'A':
                                Get(i + 1, j, k);
                                break;
                            case 'B':
                                Get(i, j + 1, k);
                                break;
                            case 'C':
                                Get(i, j, k + 1);
                                break;
                            case '?':
                                Get(i + 1, j, k);
                                Get(i, j + 1, k);
                                Get(i, j, k + 1);
                                break;
                            default:
                                break;
                        }
                    }
            ans += f[n][n][n][1][1];
        }
    printf("%u\n", ans);
}

int main()
{
    int T;
    scanf("%d%*d", &T);
    while(T -- ) Work();
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 820ms
memory: 7608kb

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: 830ms
memory: 7612kb

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:

-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 #3:

score: 20
Accepted
time: 833ms
memory: 7668kb

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: 830ms
memory: 7484kb

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: 840ms
memory: 7672kb

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
-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
0

result:

ok Accepted!!!

Test #6:

score: 0
Wrong Answer
time: 810ms
memory: 7608kb

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
-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
0

result:

wrong answer Your answer is wrong in testcase 60

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 2216ms
memory: 7628kb

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:

-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
3540689702

result:

wrong answer Your answer is wrong in testcase 60

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%