QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834406 | #9912. 比赛 | hhoppitree# | 20 | 3ms | 8628kb | C++14 | 2.5kb | 2024-12-27 16:44:12 | 2024-12-27 16:44:13 |
Judging History
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]) {
} 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;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 6100kb
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: 10
Accepted
Test #7:
score: 10
Accepted
time: 0ms
memory: 6940kb
input:
30 BRBRRBRBBRBRBBRBBRBBRBBRBBRRBR
output:
0 0 0 0 0 0 0 0 0 472322155 341149300 936998100 663102283 980872253 804068473 305737372 759992827 435714306 53578403 194953860 138874148 917648147 411689713 842676190 596563600 507144388 897742572 313213524 497244336 51840810 817612587 54680186 71915231 72873026 821631943 995017144 498609486 3059714...
result:
ok 61 numbers
Test #8:
score: 10
Accepted
time: 1ms
memory: 3992kb
input:
22 BBRBBBBBBRRBBBBBRBBRRR
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 924987037 156012064 107229157 248572175 432214610 406077427 757195611 771797280 158444708 188622978 686829181 401546354 42086613 449742960 705260458 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 45 numbers
Test #9:
score: 10
Accepted
time: 1ms
memory: 6572kb
input:
20 BBRRBRBRRBRBRBBBRBBR
output:
0 0 0 0 0 286654464 222724085 735477518 879768762 657155621 374608160 460760901 656626201 53371769 887650550 244126084 566589532 369043471 13985447 545833072 665867348 402681618 982192403 980096579 75631823 459258583 316493810 14432256 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 41 numbers
Test #10:
score: 10
Accepted
time: 0ms
memory: 6808kb
input:
30 BBBBBBBBBBBBRRRRRRRRRRRRRRRRRR
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 72334032 773765874 668869580 537072304 212520714 45699554 506161101 586251470 769359418 430456696 225960959 730416214 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
ok 61 numbers
Test #11:
score: 10
Accepted
time: 1ms
memory: 6000kb
input:
30 BBBBBBBBBBBBBBBBBBRRBBBBBBBBBR
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 932292693 684973968 256288178 934546083 837322348 421266285 493934008 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:
ok 61 numbers
Test #12:
score: 10
Accepted
time: 1ms
memory: 5996kb
input:
30 BBBBBBBBBBBBBBRRBBBBBBBBBBBBBR
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 134057753 834266559 817644314 588299868 727219703 470864360 988271006 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:
ok 61 numbers
Subtask #3:
score: 10
Accepted
Test #13:
score: 10
Accepted
time: 2ms
memory: 6404kb
input:
50 BBBRRRBRRRBBRBRRRBRRRBRRRRRRRBBRRRBBBRRBRRRBBRRRBR
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 840671540 723021899 421289556 784273730 313155366 411853797 393531340 678567 633540304 934617986 894818850 619909812 260582295 277020059 767648419 229952267 653528115 836441240 93744680 503596241 14610311 176768975 411266579 97000158 68055577 77093992 819156...
result:
ok 101 numbers
Test #14:
score: 10
Accepted
time: 0ms
memory: 4840kb
input:
30 BRRBRBRRBBBRRBBBBBRBRRBRBBRBBB
output:
0 0 0 0 0 0 577002683 677691869 405169704 881214934 522606625 485568739 268429513 865028369 394347342 453955082 864056906 944433445 145565620 567872744 393691753 186892897 922995475 732239080 38136676 808302887 475120602 534045005 594213186 396919948 513486569 540062329 366918440 444240351 247203479...
result:
ok 61 numbers
Test #15:
score: 10
Accepted
time: 3ms
memory: 8628kb
input:
46 BBBBRBBRBBBRRRRRBRBRBRRBRRRBRBBBBRBRBRRBBRRBRR
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 660761508 644702590 897844805 750106369 686938853 932481915 574174221 294213960 668854749 706431613 100498282 960168080 353092076 343099522 183983669 107126533 718310464 498363183 369572616 972830870 716934606 763584223 595161946 338630761 717786690 849278305 262900429 ...
result:
ok 93 numbers
Test #16:
score: 10
Accepted
time: 0ms
memory: 8012kb
input:
50 BBBBBBBBBBBBBBBBRRRRRRRRRRRRRRRRBBBBBBBBBBBBBBBBBB
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 831392418 604328086 961184705 819434558 450033872 572811813 637284475 638881547 844766974 157789854 461172724 939131107 246938607 141044738 596024030 462151101 314563907 17327804 409217009 118114813 134339259 787410036 777008722 896388601 748783660 851950968 85661...
result:
ok 101 numbers
Test #17:
score: 10
Accepted
time: 1ms
memory: 6696kb
input:
49 RBBBBBRBRBBBBBBBBBBBBBBBBRBBBBBRBBBBRBBBBBBBBBBBR
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 0 0 0 607905029 969689245 927531367 354997122 672606662 890595880 747744666 352270561 749008986 17901987 544305436 246979810 221979365 894641324 406170420 985309021 772832843 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:
ok 99 numbers
Test #18:
score: 10
Accepted
time: 1ms
memory: 6588kb
input:
50 BBBBBBBBBBRBBBBBBBBBBBBBRBBBBBRBRBBBBBBBBBBBBBBBRB
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 0 0 0 0 0 0 662189982 50268982 516797152 800043454 523612648 23838524 677535558 4054488 381467635 589829657 587271506 883407480 54487000 290015930 597531274 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 0 0...
result:
ok 101 numbers
Subtask #4:
score: 0
Runtime Error
Test #19:
score: 0
Runtime Error
input:
200 RBRBRBBRBRBRRBBRBBRBRBBBRBRRBRBRBRRBRRRBRRBRRRRRBRBBRRBBRBBRBBBBRBRBRBBBRRBBRBRRRBRBRBBBBRBRRRBBBBRRRBRBBRBBBRRRRRBRRRRRBRRRRRRRBBRRBRBBRBBRRRBRRRBRRRRBRBRBRRBBRBBRRBRRRRBBRRBRBRBRRRRBBRBRRBBRRBRBBBBR
output:
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...