QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763061 | #9489. 0100 Insertion | ucup-team1004 | WA | 0ms | 3800kb | C++17 | 1.2kb | 2024-11-19 18:02:19 | 2024-11-19 18:02:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
const int N=5e2+10,mod=998244353;
int n,f[2][2][N/4][N/4*3];
char a[N];
int& F(int x,int y,int z,int w){
return f[x][y][z][N/2+w];
}
void add(int &x,int y){
(x+=y)>=mod&&(x-=mod);
}
int main(){
scanf("%d%s",&n,a+1);
reverse(a+1,a+1+n);
int now=1,las=0;
F(now,1,0,0)=1;
for(int i=0;i<n;i++){
swap(now,las);
if(a[i+1]!='0'){
for(int j=0;j<=n/4;j++){
for(int k=-n/2;k<=n/4;k++){
add(F(now,1,max(j,k+3),k+3),F(las,0,j,k));
}
}
}
if(a[i+1]!='1'){
for(int x:{0,1}){
for(int j=0;j<=n/4;j++){
for(int k=-n/2;k<=n/4;k++){
add(F(now,0,j,k-1),F(las,x,j,k));
}
}
}
}
for(int x:{0,1}){
for(int j=0;j<=n/4;j++){
for(int k=-n/2;k<=n/4;k++){
F(las,x,j,k)=0;
}
}
}
}
int ans=0;
for(int i=0;i<=n/4;i++)add(ans,F(now,0,i,0));
cout<<ans<<endl;
return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
input:
8 0??0?100
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
4 ?10?
output:
1
result:
ok "1"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3800kb
input:
28 ???????????0???0??????1???0?
output:
7123
result:
wrong answer 1st words differ - expected: '2023', found: '7123'