QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401081#8552. SticksBronyaAC ✓263ms189156kbC++141.2kb2024-04-27 21:36:482024-04-27 21:36:49

Judging History

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

  • [2024-04-27 21:36:49]
  • 评测
  • 测评结果:AC
  • 用时:263ms
  • 内存:189156kb
  • [2024-04-27 21:36:48]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
int n;
char s[3005][3005];
int f[3005],g[3005];
int sav[3005][3005],sav2[3005][3005],sav3[3005][3005],sav4[3005][3005];
int dp[3005][3005];
const int mo=998244353;
int add(int u,int v){
	return (u+v>=mo?u+v-mo:u+v);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		f[0]=1;g[0]=0;
		sav[i][0]=1;
		for(int j=1;j<=n;j++){
			f[j]=g[j]=0;
			if(s[i][j]!='0')f[j]=f[j-1];
			if(s[i][j]!='1')g[j]=add(g[j-1],f[j-1]);
			sav[i][j]=add(f[j],g[j]);sav4[i][j]=g[j];
		}
	}
	for(int i=1;i<=n;i++){
		f[0]=1;g[0]=0;
		sav2[0][i]=1;sav3[0][i]=1;
		for(int j=1;j<=n;j++){
			f[j]=g[j]=0;
			if(s[j][i]!='0')f[j]=f[j-1];
			if(s[j][i]!='1')g[j]=add(g[j-1],f[j-1]);
			sav2[j][i]=add(f[j],g[j]);sav3[j][i]=f[j];
		}
	}
	dp[n+1][n]=1;
	for(int i=n;i>=1;i--){
		int sum=0;
		for(int j=n;j>=0;j--){
			dp[i][j]=dp[i+1][j]*1ll*sav[i][j]%mo;
			dp[i][j]=add(dp[i][j],sum*1ll*(j!=n?sav3[i][j+1]:1)%mo*1ll*sav4[i][j]%mo);
			if(j+1<=n)sum=1ll*sum*sav2[i][j+1]%mo;
			sum=add(sum,dp[i+1][j]);
//			cerr<<dp[i][j]<<endl;
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)ans=add(ans,dp[1][i]);
	printf("%d\n",ans);
	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 14080kb

input:

2
??
??

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: 0
Accepted
time: 2ms
memory: 14220kb

input:

5
??1??
?1??0
??0??
???1?
??1??

output:

3144

result:

ok 1 number(s): "3144"

Test #3:

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

input:

10
0000000000
??????????
??????????
??????????
??????????
??????????
??????????
??????????
??????????
??????????

output:

361458985

result:

ok 1 number(s): "361458985"

Test #4:

score: 0
Accepted
time: 189ms
memory: 189108kb

input:

3000
??????????????????????????????????????????????????????????0?????????????????????0??????????????????????????????????????????????????????????????????????????????????????0???????????????????????????????????????????0???????????????????????????????????????????????????????????????????????????????????...

output:

56427841

result:

ok 1 number(s): "56427841"

Test #5:

score: 0
Accepted
time: 237ms
memory: 189088kb

input:

3000
????????????????????????????????????????0??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

145247225

result:

ok 1 number(s): "145247225"

Test #6:

score: 0
Accepted
time: 252ms
memory: 189044kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

925248762

result:

ok 1 number(s): "925248762"

Test #7:

score: 0
Accepted
time: 256ms
memory: 189104kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

845505610

result:

ok 1 number(s): "845505610"

Test #8:

score: 0
Accepted
time: 256ms
memory: 188964kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

123028256

result:

ok 1 number(s): "123028256"

Test #9:

score: 0
Accepted
time: 239ms
memory: 188964kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????1???1??????????????????????????????????????????????????????????????????????1????????????????????????????????????????????????????????????????...

output:

242286033

result:

ok 1 number(s): "242286033"

Test #10:

score: 0
Accepted
time: 237ms
memory: 189080kb

input:

3000
??????????????????????????1????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

448817936

result:

ok 1 number(s): "448817936"

Test #11:

score: 0
Accepted
time: 254ms
memory: 188972kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

621258555

result:

ok 1 number(s): "621258555"

Test #12:

score: 0
Accepted
time: 251ms
memory: 189104kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

552098298

result:

ok 1 number(s): "552098298"

Test #13:

score: 0
Accepted
time: 262ms
memory: 189044kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

190431651

result:

ok 1 number(s): "190431651"

Test #14:

score: 0
Accepted
time: 161ms
memory: 189108kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 246ms
memory: 189080kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

641634738

result:

ok 1 number(s): "641634738"

Test #16:

score: 0
Accepted
time: 246ms
memory: 189156kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

434138343

result:

ok 1 number(s): "434138343"

Test #17:

score: 0
Accepted
time: 263ms
memory: 188940kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

70334815

result:

ok 1 number(s): "70334815"

Test #18:

score: 0
Accepted
time: 260ms
memory: 189144kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

26692788

result:

ok 1 number(s): "26692788"

Test #19:

score: 0
Accepted
time: 260ms
memory: 189148kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

513359183

result:

ok 1 number(s): "513359183"

Test #20:

score: 0
Accepted
time: 257ms
memory: 189148kb

input:

3000
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

144382583

result:

ok 1 number(s): "144382583"

Test #21:

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

input:

1
0

output:

1

result:

ok 1 number(s): "1"

Test #22:

score: 0
Accepted
time: 2ms
memory: 14076kb

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 2ms
memory: 14152kb

input:

2
10
01

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 190ms
memory: 189100kb

input:

3000
1???11111??1???1?1?1111?1111??11?11?????11?1?1?1?1?1???111???111???11?1???11?11??1?11???1??111???11??1????1??1?111??1111?1??1?1?1?1111?1??11?111?1?1??11???11?1?1111??11???????1????1???1?1??111?11?1??1111?1111?1????11?11?1??1?1???1????11?1111?1?1?1??1111???1?11?111?1????1?1?11?11???1???????111?1...

output:

354584112

result:

ok 1 number(s): "354584112"

Test #25:

score: 0
Accepted
time: 195ms
memory: 189148kb

input:

3000
111?1111??11??1?1??1???1?????111???1?11111??1?111?1??1?1????11?11111??1??1?11??11????1??11??11?1???1111???1?11?111?11?1???1?11?11?111?11??1???????1?1??11?1111??????1?1??1111????111111111???1?111??1???111???1?11??11?1??1?11??1?1?111?????1??11?1????1???11??1?11?11111?1111??1?1?1?1???1?11111?1?111...

output:

46093564

result:

ok 1 number(s): "46093564"

Test #26:

score: 0
Accepted
time: 169ms
memory: 189152kb

input:

3000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Test #27:

score: 0
Accepted
time: 176ms
memory: 189024kb

input:

3000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Extra Test:

score: 0
Extra Test Passed