QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#767039 | #9489. 0100 Insertion | simonG | RE | 2ms | 6124kb | C++14 | 960b | 2024-11-20 19:39:15 | 2024-11-20 19:39:16 |
Judging History
answer
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int mod=998244353;
int n,f[2][175][2][805],*g[2][175][2];
char s[505];
void add(int &x,int y) {
x+=y;
if(x>=mod) x-=mod;
}
int main() {
scanf("%d%s",&n,s+1);
reverse(s+1,s+1+n);
for(int j=0; j<=174; j++) for(int o=0; o<=1; o++) for(int p=0; p<=1; p++)
g[o][j][p]=&f[o][j][p][400];
g[0][0][0][0]=1;
for(int i=1,o=1; i<=n; i++,o^=1) {
memset(f[o],0,sizeof f[o]);
if(s[i]!='1') {
for(int j=0; j<=i/3+1; j++) for(int k=-i; k<=j; k++) {
add(g[o][j][0][k-1],g[o^1][j][1][k]);
add(g[o][j][0][k-1],g[o^1][j][0][k]);
}
}
if(s[i]!='0') {
for(int j=0; j<=i/3+1; j++) for(int k=-i; k<=j; k++) {
if(k+2>j) continue;
add(g[o][max(j,k+3)][1][k+3],g[o^1][j][0][k]);
}
}
}
int res=0;
for(int j=0; j<=n/3+1; j++) add(res,g[n&1][j][0][0]);
printf("%d\n",res);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6040kb
input:
8 0??0?100
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 6116kb
input:
4 ?10?
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 6124kb
input:
28 ???????????0???0??????1???0?
output:
2023
result:
ok "2023"
Test #4:
score: 0
Accepted
time: 1ms
memory: 6112kb
input:
4 ????
output:
1
result:
ok "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 6120kb
input:
8 11111111
output:
0
result:
ok "0"
Test #6:
score: -100
Runtime Error
input:
500 ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...