QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#673862 | #9489. 0100 Insertion | professor_panda | WA | 0ms | 3580kb | C++14 | 1.8kb | 2024-10-25 11:10:49 | 2024-10-25 11:10:49 |
Judging History
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 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 = min preA, C = 0 or 1
vector<vector<vector<int>>> m(N+1, vector<vector<int>>(N/2+1, vector<int>(2, 0)));
m[2+N/4][N/4][0] = 1;
int miA = 0, maA = 2, maB = 0;
for (int pos = 2; pos <N;pos++) {
vector<vector<vector<int>>> mp(N+1, vector<vector<int>>(N/2+1, vector<int>(2, 0)));
if (S[pos] == '?' || S[pos] == '0') {
// 0
for (int a = miA + 1; a <= min(N, maA + 1); a++) {
for (int b = 0; b <= min(a, N/2); b++) {
mp[a][b][0] = (m[a - 1][b][0] + m[a - 1][b][1]) % MOD;
miA = min(miA, a);
maA = max(maA, a);
}
}
}
if (S[pos] == '?' || S[pos] == '1') {
// 1
for (int a = max(0, miA - 3); a <= min(N-3, maA - 3); a++) {
for (int b = 0; b <= min(a, N/2); b++) {
mp[a][b][1] = m[a+3][b][0];
if (a == b && b < N/2) {
mp[a][b][1] += m[a+3][b+1][0];
mp[a][b][1] %= MOD;
}
miA = min(miA, a);
maA = max(maA, a);
}
}
}
swap(m, mp);
}
LL ans = 0;
for (int b = 0; b <= N/4; b++) {
ans += m[N/4][b][0];
ans %= MOD;
}
cout << ans << endl;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3580kb
input:
8 0??0?100
output:
0
result:
wrong answer 1st words differ - expected: '2', found: '0'