QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746004#9489. 0100 Insertionucup-team1004AC ✓21ms4560kbC++171.2kb2024-11-14 12:55:352024-11-14 12:55:35

Judging History

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

  • [2024-11-14 12:55:35]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:4560kb
  • [2024-11-14 12:55:35]
  • 提交

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<=i/3&&j<=n/4;j++){
				for(int k=max(-n/2,-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=max(-n/2,-i+j*4);k<=j;k++){
						add(F(now,0,j,k-1),F(las,x,j,k));
					}
				}
			}
		}
		for(int x:{0,1}){
			for(int j=0;j<=i/3&&j<=n/4;j++){
				for(int k=max(-n/2,-i+j*4);k<=j;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: 3836kb

input:

8
0??0?100

output:

2

result:

ok "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

4
?10?

output:

1

result:

ok "1"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

28
???????????0???0??????1???0?

output:

2023

result:

ok "2023"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

4
????

output:

1

result:

ok "1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

8
11111111

output:

0

result:

ok "0"

Test #6:

score: 0
Accepted
time: 21ms
memory: 4420kb

input:

500
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

870731023

result:

ok "870731023"

Test #7:

score: 0
Accepted
time: 21ms
memory: 4500kb

input:

500
???????????????????0???????????????????????????????????????0??????????????????????1???????????????????????????????????????00????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????1???????????????????????????????????...

output:

763641704

result:

ok "763641704"

Test #8:

score: 0
Accepted
time: 7ms
memory: 4352kb

input:

344
?0???????????1???????0?0?????0?????????????0?0????0?0??1??0?????0??0???1?????0????00?????1?????1????????1?????10????0??????????1????0???1????????0???10?????1?0?0???1??????????0??0???1?0??00??0???????001????????1????1??????1?0????1??????????????????1????1????????????0???????????01?1??????0?0?????...

output:

273835616

result:

ok "273835616"

Test #9:

score: 0
Accepted
time: 0ms
memory: 4064kb

input:

152
?1???1??????????????????00??????????0?????0????????0??1?????0????0????????0????010???????????????1??1??????0?10??1????0???????????????1?????0???1???????

output:

539361138

result:

ok "539361138"

Test #10:

score: 0
Accepted
time: 3ms
memory: 4160kb

input:

216
???????1?????1??1????1???1?????????????0?1???????????????????????????????????????????????1?????????????????10???0???1???????????????????????1????????????0???????0??????0?????????1???????????????????????1?????????0???

output:

336079328

result:

ok "336079328"

Test #11:

score: 0
Accepted
time: 6ms
memory: 4300kb

input:

316
??????00?????????????????????1??????????????????0?????????????????0??0??????0???1??1?????????0??????????????????????0?????????0?0?1??0?????1?1??????1?1?????????????????????????????????0??????????????????????10???????1???????????1?????????????1????1????????????0????????????????1????1???0??0??1???...

output:

919261244

result:

ok "919261244"

Test #12:

score: 0
Accepted
time: 6ms
memory: 4344kb

input:

340
?0?001??1?0????1?????1???01?????????1??01??0???1???1?????????????0?1??????1??1?10??0????????10?????1????1?010???1?????????????1???????1????01???????1???????00???1?0?00??0????????00???0??????1??1?1?????10??1????0??1????1????0????????0????0??????00?0??00???1??001????????0?1?????????????????0???1??...

output:

743485908

result:

ok "743485908"

Test #13:

score: 0
Accepted
time: 10ms
memory: 4404kb

input:

392
??????0??????????10???????????????????????1????????1???????0???????????0??????????????101???????????????????????0??????????0??0??????????1?????1???????????????????1?0?????????????1???????????????????????1????????0???0?????1????????????????0??????1?????????????0????????????????0?????????????????1...

output:

213859453

result:

ok "213859453"

Test #14:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

96
????????0??1??1??????????????????????????1?0?????0??????1?????????1?0?????00??????????1???1?????

output:

860127276

result:

ok "860127276"

Test #15:

score: 0
Accepted
time: 1ms
memory: 3876kb

input:

116
???????????????????????????????01?1???????????????0?00????0?????????????????1?0?????????????????1???????????????00??

output:

717954632

result:

ok "717954632"

Test #16:

score: 0
Accepted
time: 4ms
memory: 4108kb

input:

280
?????1????0??0??????1????????0????0?1?0????????00???0???????0????0???????????1?0?1???????????1?????10????1??????100??????????1?1?????01?1??????0????01??1???1?????0????????0?1?0???????????01??00??????1?????????????????1?1?????????1????????????????0????????????????????????0????????

output:

553679844

result:

ok "553679844"

Test #17:

score: 0
Accepted
time: 3ms
memory: 4224kb

input:

260
????????0????0???????????????1???????0?00??0???????????????0??????0?????1?????????????????????????????????????0???????1????????0??????????????????????1???????????????????1?0????1???????00?0????10???????????0?1?10??????????????????0??0???????1???????1??1???????

output:

121486637

result:

ok "121486637"

Test #18:

score: 0
Accepted
time: 20ms
memory: 4380kb

input:

500
??0????1???1??????1?1??????????????????????????????????0??0??????????????????????1???????01????????0???0???????????????????????1????????1??????????????1????????0?1???0?????0???????????????????0??????????????1????????0???????0?0??????????????0???????1???????1??????????????????????????0????0??????...

output:

397451125

result:

ok "397451125"

Test #19:

score: 0
Accepted
time: 20ms
memory: 4476kb

input:

500
??????1???????????????????0????????????????????????0??????0???????????1??????????10???0???0?????????????1??1????????0??????1???????????00????????????0???????????????????1??0???0????0?????????????0?????????????????????????????????????0????0??????????1??????????????????????????????????????????????...

output:

248838567

result:

ok "248838567"

Test #20:

score: 0
Accepted
time: 20ms
memory: 4436kb

input:

500
?0??0????1???????????????????????????1????????????????????0????????1????????????????1????0?????????????1???????????1?0????????????????????0?????????????0????0????????????1????????1????????????????0???0?1???1???1???????????1?????1???0??????????1????????1?????1???0?1???????????1???????????????????...

output:

53824210

result:

ok "53824210"

Test #21:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

76
????0????????0??0???1??0??????00?0????0???1??????1?0????0?1?????????????1???

output:

205686585

result:

ok "205686585"

Test #22:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

24
?0?0?????0??????????????

output:

587

result:

ok "587"

Test #23:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

76
?????0?????????????????0????????????????????????????1???0???????????????????

output:

83575746

result:

ok "83575746"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

28
00???0???0?0??0???0???0?????

output:

859

result:

ok "859"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3756kb

input:

44
?00??1???00??1???0??1?100??1?0???0??1???0???

output:

63

result:

ok "63"

Test #26:

score: 0
Accepted
time: 15ms
memory: 4424kb

input:

444
???0???0???????????????1?????1??????0?????1??????1??????????10?1???????????????????????????????1?1??00?0??0????0??????????1???????101?0????10??????????????0?0???????1???????????????1????????0?????????1????????????1???0??????????????????????????0??????1??????????0???10??1???????????01????????????...

output:

847293915

result:

ok "847293915"

Test #27:

score: 0
Accepted
time: 17ms
memory: 4560kb

input:

484
?????1?1???????????1?????1??????????0?1???????????1?????0?1???0000?1?1?0?00????1????0?0?00?????????????????????1????????1?01??????01??1?????0??????0???000?????????1????????0?1??01?????0???1???0?????1???0???????0?????1?1?0??0???????01????????0???1???0??0???0?????????????????1??????1???10??1010???...

output:

679474848

result:

ok "679474848"

Test #28:

score: 0
Accepted
time: 15ms
memory: 4516kb

input:

456
?????0???????????????0?????1???????0???1??????????????????1??????1?????????????1??????1??????????0??????????????1????????????????????1??????????1???0???0??1???1????????00??0?????1???0?????????????1?0??1??1?1???0???1????????????0???????????????0?0??0?????0????????01?????????????????????????????10...

output:

920943116

result:

ok "920943116"

Test #29:

score: 0
Accepted
time: 18ms
memory: 4548kb

input:

484
????????????????????????????????0????1???1???????1????????1?????????0?????1??1??????????????????????1???????01???????????????????1??1???????????????1?1?0?0??1????????1??1???????????????????????????0?????????????0?????????????1????0??????1?????????0?0??????????1????????????1??????????????????????...

output:

453361220

result:

ok "453361220"

Test #30:

score: 0
Accepted
time: 14ms
memory: 4372kb

input:

448
?1?01??1????01?10????1???0????????????10????0??????1????1??????1?????1?0??1????101?1????1??????????????0?????1???0???????01?0?1?1????1???1?01?????????????0?1???1???01????0???????????????1??????01?1??????1?1?1??0???0?????????1????????1??1?0?1?0???????????????1?????1???0?0?????0????0??0???????????...

output:

84175678

result:

ok "84175678"

Test #31:

score: 0
Accepted
time: 17ms
memory: 4480kb

input:

480
?0?????????????????????0???00???1???0?????1?????????1??????????1?????1????????0??????????1????0???10?????????1????1????0?????0???01??????????0?????0???0?????????0???????01??????????????0????????0?????1????1?0??0?0????????????????1???1??01????????????1????0??????0??????1??1???????????????????????...

output:

247404334

result:

ok "247404334"

Test #32:

score: 0
Accepted
time: 18ms
memory: 4376kb

input:

492
??????00??????0??0??????????1???1?1?010????????????????????00???1???0?????0???????1?????????0???????1?????????????1???10???0?????????????????0??????????????0??????1???0????0?0???0??100?0?????????1??1????1???????????1????1??0?????????00??????1??1??????1????01?1?0??????0???????1????????????1??0???...

output:

487405442

result:

ok "487405442"

Test #33:

score: 0
Accepted
time: 15ms
memory: 4528kb

input:

456
????1???????????1???1????0????????????????????????????????????1???????0?????1???1?1??????????????????????????1?????????1?00??????????10?0????????????1??????????1?0????????1?1?????????????????0??????0???????1???????????????????????????0????????0??????1??????????0??1???????????????????????????????...

output:

884555628

result:

ok "884555628"

Test #34:

score: 0
Accepted
time: 16ms
memory: 4376kb

input:

460
??????1????1??????????0??0?????????????????0?????0???????????1?????????????1???????????01???????0????????????0???0???????????????????????????1???0????0??????????0??0??????1????0???????????????01?????????????0???????????????????????????????1????0????0????1??????1???????1???0??????????????????????...

output:

244536851

result:

ok "244536851"

Test #35:

score: 0
Accepted
time: 15ms
memory: 4464kb

input:

456
???????1?1????????????????00??????????1??1?0???????0??????0??????????0??1?????0??1???0?1??1?1?1???00?10?0???01??????????????0???01?0??000?1????1????????0????1?1????1???01???0?????1?0??????????1???0???1?1??????????01???1?????0???????0?1????1???1?0??0????1????0?0??1????????????0???0?????0??????01?...

output:

890392505

result:

ok "890392505"

Extra Test:

score: 0
Extra Test Passed