QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#673976#9489. 0100 Insertionprofessor_pandaAC ✓550ms6176kbC++141.8kb2024-10-25 12:43:012024-10-25 12:43:01

Judging History

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

  • [2024-10-25 12:43:01]
  • 评测
  • 测评结果:AC
  • 用时:550ms
  • 内存:6176kb
  • [2024-10-25 12:43:01]
  • 提交

answer

#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

typedef long long LL;
LL MOD = 998244353;
int m[2][505][305][2];
int o = 0;
int main() {
    int N;
    cin >> N;
    vector<char> S(N);
    for (int i = 0; i < N; i++) cin >> S[N- 1 - i];
    if (S[0] == '1' || S[1] == '1' || S[N - 1] == '1') {
        cout << 0 << endl;
        return 0;
    }

    // m[A][B][C]: A = (# of 0) - 3*(# of 1) + N / 4, B = A - min preA, C = 0 or 1
    // vector<vector<vector<int>>> m(N+1, vector<vector<int>>(N/2+1, vector<int>(2, 0)));
    m[o][2+N/4][2][0] = 1;
    for (int pos = 2; pos <N;pos++) {
        o = 1 - o;
        for (int a = 0; a <= N; a++) {
            for (int b = 0; b <= N/2; b++) {
                for (int c = 0; c < 2; c++) {
                    m[o][a][b][c] = 0;
                }
            }
        }
        // vector<vector<vector<int>>> mp(N+1, vector<vector<int>>(N/2+1, vector<int>(2, 0)));
        for (int a = 0; a <= N; a++) {
            for (int b = 0; b <= N/2; b++) {
                for (int c = 0; c < 2; c++) {
                    int t = m[1-o][a][b][c];
                    if (S[pos] != '1' && a+1 <= N && b+1 <= N/2) {
                        m[o][a+1][b+1][0] += t;
                        m[o][a+1][b+1][0] %= MOD; 
                    }
                    if (S[pos] != '0' && c == 0 && b > 1 && a-3 >= 0) {
                        m[o][a-3][max(b-3, 0)][1] += t;
                        m[o][a-3][max(b-3, 0)][1] %= MOD;
                    }
                }
            }
        }
        // swap(m, mp);
    }
    LL ans = 0;
    for (int b = 0; b <= N/4; b++) {
        ans += m[0][N/4][b][0];
        ans %= MOD;
    }
    cout << ans << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3744kb

input:

8
0??0?100

output:

2

result:

ok "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

4
?10?

output:

1

result:

ok "1"

Test #3:

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

input:

28
???????????0???0??????1???0?

output:

2023

result:

ok "2023"

Test #4:

score: 0
Accepted
time: 1ms
memory: 5660kb

input:

4
????

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

8
11111111

output:

0

result:

ok "0"

Test #6:

score: 0
Accepted
time: 550ms
memory: 5892kb

input:

500
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

870731023

result:

ok "870731023"

Test #7:

score: 0
Accepted
time: 550ms
memory: 5964kb

input:

500
???????????????????0???????????????????????????????????????0??????????????????????1???????????????????????????????????????00????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????1???????????????????????????????????...

output:

763641704

result:

ok "763641704"

Test #8:

score: 0
Accepted
time: 165ms
memory: 5204kb

input:

344
?0???????????1???????0?0?????0?????????????0?0????0?0??1??0?????0??0???1?????0????00?????1?????1????????1?????10????0??????????1????0???1????????0???10?????1?0?0???1??????????0??0???1?0??00??0???????001????????1????1??????1?0????1??????????????????1????1????????????0???????????01?1??????0?0?????...

output:

273835616

result:

ok "273835616"

Test #9:

score: 0
Accepted
time: 11ms
memory: 4436kb

input:

152
?1???1??????????????????00??????????0?????0????????0??1?????0????0????????0????010???????????????1??1??????0?10??1????0???????????????1?????0???1???????

output:

539361138

result:

ok "539361138"

Test #10:

score: 0
Accepted
time: 39ms
memory: 5732kb

input:

216
???????1?????1??1????1???1?????????????0?1???????????????????????????????????????????????1?????????????????10???0???1???????????????????????1????????????0???????0??????0?????????1???????????????????????1?????????0???

output:

336079328

result:

ok "336079328"

Test #11:

score: 0
Accepted
time: 133ms
memory: 5292kb

input:

316
??????00?????????????????????1??????????????????0?????????????????0??0??????0???1??1?????????0??????????????????????0?????????0?0?1??0?????1?1??????1?1?????????????????????????????????0??????????????????????10???????1???????????1?????????????1????1????????????0????????????????1????1???0??0??1???...

output:

919261244

result:

ok "919261244"

Test #12:

score: 0
Accepted
time: 154ms
memory: 5380kb

input:

340
?0?001??1?0????1?????1???01?????????1??01??0???1???1?????????????0?1??????1??1?10??0????????10?????1????1?010???1?????????????1???????1????01???????1???????00???1?0?00??0????????00???0??????1??1?1?????10??1????0??1????1????0????????0????0??????00?0??00???1??001????????0?1?????????????????0???1??...

output:

743485908

result:

ok "743485908"

Test #13:

score: 0
Accepted
time: 257ms
memory: 5456kb

input:

392
??????0??????????10???????????????????????1????????1???????0???????????0??????????????101???????????????????????0??????????0??0??????????1?????1???????????????????1?0?????????????1???????????????????????1????????0???0?????1????????????????0??????1?????????????0????????????????0?????????????????1...

output:

213859453

result:

ok "213859453"

Test #14:

score: 0
Accepted
time: 0ms
memory: 5868kb

input:

96
????????0??1??1??????????????????????????1?0?????0??????1?????????1?0?????00??????????1???1?????

output:

860127276

result:

ok "860127276"

Test #15:

score: 0
Accepted
time: 7ms
memory: 4340kb

input:

116
???????????????????????????????01?1???????????????0?00????0?????????????????1?0?????????????????1???????????????00??

output:

717954632

result:

ok "717954632"

Test #16:

score: 0
Accepted
time: 90ms
memory: 5884kb

input:

280
?????1????0??0??????1????????0????0?1?0????????00???0???????0????0???????????1?0?1???????????1?????10????1??????100??????????1?1?????01?1??????0????01??1???1?????0????????0?1?0???????????01??00??????1?????????????????1?1?????????1????????????????0????????????????????????0????????

output:

553679844

result:

ok "553679844"

Test #17:

score: 0
Accepted
time: 74ms
memory: 4760kb

input:

260
????????0????0???????????????1???????0?00??0???????????????0??????0?????1?????????????????????????????????????0???????1????????0??????????????????????1???????????????????1?0????1???????00?0????10???????????0?1?10??????????????????0??0???????1???????1??1???????

output:

121486637

result:

ok "121486637"

Test #18:

score: 0
Accepted
time: 532ms
memory: 6176kb

input:

500
??0????1???1??????1?1??????????????????????????????????0??0??????????????????????1???????01????????0???0???????????????????????1????????1??????????????1????????0?1???0?????0???????????????????0??????????????1????????0???????0?0??????????????0???????1???????1??????????????????????????0????0??????...

output:

397451125

result:

ok "397451125"

Test #19:

score: 0
Accepted
time: 533ms
memory: 5968kb

input:

500
??????1???????????????????0????????????????????????0??????0???????????1??????????10???0???0?????????????1??1????????0??????1???????????00????????????0???????????????????1??0???0????0?????????????0?????????????????????????????????????0????0??????????1??????????????????????????????????????????????...

output:

248838567

result:

ok "248838567"

Test #20:

score: 0
Accepted
time: 528ms
memory: 5968kb

input:

500
?0??0????1???????????????????????????1????????????????????0????????1????????????????1????0?????????????1???????????1?0????????????????????0?????????????0????0????????????1????????1????????????????0???0?1???1???1???????????1?????1???0??????????1????????1?????1???0?1???????????1???????????????????...

output:

53824210

result:

ok "53824210"

Test #21:

score: 0
Accepted
time: 3ms
memory: 5980kb

input:

76
????0????????0??0???1??0??????00?0????0???1??????1?0????0?1?????????????1???

output:

205686585

result:

ok "205686585"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

24
?0?0?????0??????????????

output:

587

result:

ok "587"

Test #23:

score: 0
Accepted
time: 2ms
memory: 3868kb

input:

76
?????0?????????????????0????????????????????????????1???0???????????????????

output:

83575746

result:

ok "83575746"

Test #24:

score: 0
Accepted
time: 1ms
memory: 3912kb

input:

28
00???0???0?0??0???0???0?????

output:

859

result:

ok "859"

Test #25:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

44
?00??1???00??1???0??1?100??1?0???0??1???0???

output:

63

result:

ok "63"

Test #26:

score: 0
Accepted
time: 368ms
memory: 5836kb

input:

444
???0???0???????????????1?????1??????0?????1??????1??????????10?1???????????????????????????????1?1??00?0??0????0??????????1???????101?0????10??????????????0?0???????1???????????????1????????0?????????1????????????1???0??????????????????????????0??????1??????????0???10??1???????????01????????????...

output:

847293915

result:

ok "847293915"

Test #27:

score: 0
Accepted
time: 454ms
memory: 5880kb

input:

484
?????1?1???????????1?????1??????????0?1???????????1?????0?1???0000?1?1?0?00????1????0?0?00?????????????????????1????????1?01??????01??1?????0??????0???000?????????1????????0?1??01?????0???1???0?????1???0???????0?????1?1?0??0???????01????????0???1???0??0???0?????????????????1??????1???10??1010???...

output:

679474848

result:

ok "679474848"

Test #28:

score: 0
Accepted
time: 400ms
memory: 5752kb

input:

456
?????0???????????????0?????1???????0???1??????????????????1??????1?????????????1??????1??????????0??????????????1????????????????????1??????????1???0???0??1???1????????00??0?????1???0?????????????1?0??1??1?1???0???1????????????0???????????????0?0??0?????0????????01?????????????????????????????10...

output:

920943116

result:

ok "920943116"

Test #29:

score: 0
Accepted
time: 477ms
memory: 6112kb

input:

484
????????????????????????????????0????1???1???????1????????1?????????0?????1??1??????????????????????1???????01???????????????????1??1???????????????1?1?0?0??1????????1??1???????????????????????????0?????????????0?????????????1????0??????1?????????0?0??????????1????????????1??????????????????????...

output:

453361220

result:

ok "453361220"

Test #30:

score: 0
Accepted
time: 357ms
memory: 5720kb

input:

448
?1?01??1????01?10????1???0????????????10????0??????1????1??????1?????1?0??1????101?1????1??????????????0?????1???0???????01?0?1?1????1???1?01?????????????0?1???1???01????0???????????????1??????01?1??????1?1?1??0???0?????????1????????1??1?0?1?0???????????????1?????1???0?0?????0????0??0???????????...

output:

84175678

result:

ok "84175678"

Test #31:

score: 0
Accepted
time: 458ms
memory: 5872kb

input:

480
?0?????????????????????0???00???1???0?????1?????????1??????????1?????1????????0??????????1????0???10?????????1????1????0?????0???01??????????0?????0???0?????????0???????01??????????????0????????0?????1????1?0??0?0????????????????1???1??01????????????1????0??????0??????1??1???????????????????????...

output:

247404334

result:

ok "247404334"

Test #32:

score: 0
Accepted
time: 488ms
memory: 5952kb

input:

492
??????00??????0??0??????????1???1?1?010????????????????????00???1???0?????0???????1?????????0???????1?????????????1???10???0?????????????????0??????????????0??????1???0????0?0???0??100?0?????????1??1????1???????????1????1??0?????????00??????1??1??????1????01?1?0??????0???????1????????????1??0???...

output:

487405442

result:

ok "487405442"

Test #33:

score: 0
Accepted
time: 396ms
memory: 5764kb

input:

456
????1???????????1???1????0????????????????????????????????????1???????0?????1???1?1??????????????????????????1?????????1?00??????????10?0????????????1??????????1?0????????1?1?????????????????0??????0???????1???????????????????????????0????????0??????1??????????0??1???????????????????????????????...

output:

884555628

result:

ok "884555628"

Test #34:

score: 0
Accepted
time: 411ms
memory: 5904kb

input:

460
??????1????1??????????0??0?????????????????0?????0???????????1?????????????1???????????01???????0????????????0???0???????????????????????????1???0????0??????????0??0??????1????0???????????????01?????????????0???????????????????????????????1????0????0????1??????1???????1???0??????????????????????...

output:

244536851

result:

ok "244536851"

Test #35:

score: 0
Accepted
time: 377ms
memory: 5688kb

input:

456
???????1?1????????????????00??????????1??1?0???????0??????0??????????0??1?????0??1???0?1??1?1?1???00?10?0???01??????????????0???01?0??000?1????1????????0????1?1????1???01???0?????1?0??????????1???0???1?1??????????01???1?????0???????0?1????1???1?0??0????1????0?0??1????????????0???0?????0??????01?...

output:

890392505

result:

ok "890392505"

Extra Test:

score: 0
Extra Test Passed