QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#834405#9912. 比赛hhoppitree#0 7ms8580kbC++142.6kb2024-12-27 16:43:302024-12-27 16:43:31

Judging History

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

  • [2024-12-27 16:43:31]
  • 评测
  • 测评结果:0
  • 用时:7ms
  • 内存:8580kb
  • [2024-12-27 16:43:30]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 55, P = 998244353;

void add(int &x, long long y) {
    x = (x + y) % P;
}

int cnt[N], F[N][N][N][N], res[N << 1];

signed main() {
    int n; scanf("%d", &n);
    string S; cin >> S, S = ' ' + S;
    for (int i = 1; i <= n; ++i) cnt[i] = cnt[i - 1] + (S[i] == 'R');
    for (int i = 1; i <= n; ++i) cnt[i] = cnt[i] * 2 - i;
    F[2][S[1] == 'R' && S[2] == 'R'][S[1] == 'B' && S[2] == 'R'][S[1] == 'R' && S[2] == 'B'] = 1;
    for (int i = 2; i < n; ++i) {
        for (int a = 0; a <= i; ++a) {
            int b = a - cnt[i];
            if (b < 0 || b > i || a + b < 0 || a + b > i) continue;
            for (int c = 0; c <= (i - a - b) / 2; ++c) {
                int d = (i - a - b) / 2 - c;
                for (int e = 0; e <= (i - a - b) / 2; ++e) {
                    int f = (i - a - b) / 2 - e;
                    if (F[i][a][c][e]) {
                        printf("# %d %d %d %d %d\n", i, a, c, e, F[i][a][c][e]);
                    } else {
                        continue;
                    }
                    if (S[i + 1] == 'R') {
                        add(F[i + 1][a + 1][c][e], 1ll * F[i][a][c][e] * a);
                        add(F[i + 1][a][c + 1][e], 1ll * F[i][a][c][e] * b);
                        add(F[i + 1][a + 1][c][e], 1ll * F[i][a][c][e] * c);
                        add(F[i + 1][a + 1][c + 1][e], 1ll * F[i][a][c][e] * d);
                        if (e) add(F[i + 1][a + 1][c][e - 1], 1ll * F[i][a][c][e] * e);
                        add(F[i + 1][a + 1][c][e], 1ll * F[i][a][c][e] * f);
                    } else {
                        if (a) add(F[i + 1][a - 1][c][e + 1], 1ll * F[i][a][c][e] * a);
                        add(F[i + 1][a][c][e], 1ll * F[i][a][c][e] * b);
                        if (c) add(F[i + 1][a][c - 1][e], 1ll * F[i][a][c][e] * c);
                        add(F[i + 1][a][c][e], 1ll * F[i][a][c][e] * d);
                        add(F[i + 1][a][c][e], 1ll * F[i][a][c][e] * e);
                        add(F[i + 1][a][c][e + 1], 1ll * F[i][a][c][e] * f);
                    }
                }
            }
        }
    }
    for (int a = 0; a <= n; ++a) {
        int b = a - cnt[n];
        for (int c = 0; c <= n; ++c) {
            int d = (n - a - b) / 2 - c;
            for (int e = 0; e <= n; ++e) {
                int f = (n - a - b) / 2 - e;
                add(res[c - d - e + N], F[n][a][c][e]);
            }
        }
    }
    for (int i = -n; i <= n; ++i) {
        printf("%d%c", res[i + N], " \n"[i == n]);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5844kb

input:

17
RRBRBRRRBBRRBBBBB

output:

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

result:

wrong answer 2nd numbers differ - expected: '24883200', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 2ms
memory: 4908kb

input:

30
BRBRRBRBBRBRBBRBBRBBRBBRBBRRBR

output:

# 2 0 1 0 1
# 3 0 0 0 1
# 3 0 1 1 1
# 4 0 1 0 1
# 4 0 2 1 1
# 4 1 0 0 1
# 4 1 1 0 2
# 4 1 1 1 1
# 5 1 1 0 4
# 5 1 2 0 4
# 5 1 2 1 4
# 5 2 0 0 2
# 5 2 1 0 8
# 5 2 1 1 2
# 6 0 1 1 4
# 6 0 2 1 4
# 6 0 2 2 4
# 6 1 0 0 4
# 6 1 0 1 4
# 6 1 1 0 12
# 6 1 1 1 32
# 6 1 1 2 4
# 6 1 2 1 12
# 6 1 2 2 4
# 6 2 0 0...

result:

wrong output format Expected integer, but "#" found

Subtask #3:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 7ms
memory: 8580kb

input:

50
BBBRRRBRRRBBRBRRRBRRRBRRRRRRRBBRRRBBBRRBRRRBBRRRBR

output:

# 2 0 0 0 1
# 3 0 0 0 2
# 4 0 1 0 6
# 5 0 2 0 12
# 5 1 1 0 12
# 6 0 3 0 12
# 6 1 2 0 72
# 6 2 1 0 36
# 7 0 2 0 36
# 7 0 2 1 72
# 7 0 3 1 36
# 7 1 1 0 144
# 7 1 1 1 72
# 7 1 2 0 72
# 7 1 2 1 144
# 7 2 0 0 36
# 7 2 1 0 72
# 7 2 1 1 36
# 8 0 3 0 36
# 8 0 3 1 72
# 8 0 4 1 36
# 8 1 2 0 540
# 8 1 2 1 432
...

result:

wrong output format Expected integer, but "#" found

Subtask #4:

score: 0
Runtime Error

Test #19:

score: 0
Runtime Error

input:

200
RBRBRBBRBRBRRBBRBBRBRBBBRBRRBRBRBRRBRRRBRRBRRRRRBRBBRRBBRBBRBBBBRBRBRBBBRRBBRBRRRBRBRBBBBRBRRRBBBBRRRBRBBRBBBRRRRRBRRRRRBRRRRRRRBBRRBRBBRBBRRRBRRRBRRRRBRBRBRRBBRBBRRBRRRRBBRRBRBRBRRRRBBRBRRBBRRBRBBBBR

output:

# 2 0 0 1 1
# 3 1 0 0 1
# 3 1 1 1 1
# 4 0 0 1 1
# 4 0 1 2 1
# 4 1 0 0 1
# 4 1 0 1 2
# 4 1 1 1 1
# 5 1 0 0 1
# 5 1 0 1 1
# 5 1 1 0 1
# 5 1 1 1 6
# 5 1 1 2 1
# 5 1 2 1 1
# 5 1 2 2 1
# 5 2 0 0 4
# 5 2 0 1 2
# 5 2 1 0 2
# 5 2 1 1 4
# 6 0 0 1 1
# 6 0 0 2 1
# 6 0 1 1 1
# 6 0 1 2 6
# 6 0 1 3 1
# 6 0 2 2 1
...

result:


Subtask #5:

score: 0
Runtime Error

Test #25:

score: 0
Runtime Error

input:

500
RRBBBBRBBBRRRRBRRBBBRBBRRBRBRRBBBBRBRBBBRBBBRBBBBBBRBBRBBBBRRBBBBBBRBBBBBBRBBBBRBRRRRRRBRBBRBBBRBBRRRBRBBRRBBRBBRBBRBRRBBBBBRRRBBBRRBRBRBRRBRBBBRBBBRRRBBRBRBRRRRBBBBBBBRBRRRRRBBBBBBBRBBBRBBRRRBBRRBRRRRRBBBRBRRRRBBBBRBBBRBBBRBBBBRRBRRBRRRBBBBRRBBRRBBBBRRRRBBBBBBBBBRBRRBBRBRBBRRRBBBRBRRRBBBRRBBRBB...

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #31:

score: 0
Runtime Error

input:

3000
RRBBRRBRBBRRRRRBBRBRBRBBBBBRBBRRBBBBBRRBBBRBBBRRRBBRBBBBRRBBRRRRRRRBRRBBRRRRBBRBRRRRRBRRBRRRBRRRRRBBBRBBBRRBBBRRRBRBBBBBRBRBRBRBRBRBBRBRRRRRBBBBBRBBBRRRBBRRRBBRBBRBRBBRRBBRBBBRRBBRRBRBBRRBBBRRBRBRBRRRRRRBBBBRRRBBBRRRBBRRBRBRRBBRRBRRBBBRRRBBRBBBRBRRRRRRBRBBRRBRRBRBRBBBBRRRBBBRBBRBBBBRRRBRRBBBRRB...

output:


result: