QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#745995 | #9489. 0100 Insertion | ucup-team1004 | RE | 1ms | 4576kb | C++17 | 1.1kb | 2024-11-14 12:53:17 | 2024-11-14 12:53:17 |
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),memset(f[now],0,sizeof f[now]);
if(a[i+1]!='0'){
for(int j=0;j<=i/3&&j<=n/4;j++){
for(int k=-i+j*4;k+3<=j+1;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<=i/3&&j<=n/4;j++){
for(int k=-i+j*4;k<=j;k++){
add(F(now,0,j,k-1),F(las,x,j,k));
}
}
}
}
}
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: 4460kb
input:
8 0??0?100
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4436kb
input:
4 ?10?
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4512kb
input:
28 ???????????0???0??????1???0?
output:
2023
result:
ok "2023"
Test #4:
score: 0
Accepted
time: 1ms
memory: 4576kb
input:
4 ????
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 4568kb
input:
8 11111111
output:
0
result:
ok "0"
Test #6:
score: -100
Runtime Error
input:
500 ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...