QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#767039#9489. 0100 InsertionsimonGRE 2ms6124kbC++14960b2024-11-20 19:39:152024-11-20 19:39:16

Judging History

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

  • [2024-11-20 19:39:16]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:6124kb
  • [2024-11-20 19:39:15]
  • 提交

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
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:


result: