QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#438155#8552. SticksliqingyangAC ✓80ms47864kbC++171004b2024-06-10 11:46:452024-06-10 11:46:47

Judging History

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

  • [2024-06-10 11:46:47]
  • 评测
  • 测评结果:AC
  • 用时:80ms
  • 内存:47864kb
  • [2024-06-10 11:46:45]
  • 提交

answer

#include<iostream>
using namespace std;
const int mod=998244353;
int n,f0[3010],f1[3010],f[3010][3010];
char s[3010][3010];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i]+1;
	}
	for(int i=f[0][0]=1;i<=n;i++)
	{
		int p=n+1;
		for(int j=1,sum=f[i-1][0];j<=n;j++)
		{
			if(s[i][j]=='0')
			{
				p=j;
				break;
			}
			if(i>1&&s[i-1][j]!='1')
			{
				f[i][j]=(long long)sum*max(0,
				(f0[j]?f0[j]:i-1)-f1[j])%mod;
			}
			sum=(f[i-1][j]+(long long)sum*
			max(0,(f0[j]?f0[j]:i)-f1[j]))%mod;
		}
		for(int j=0,sum=0;j<=n;j++)
		{
			sum=sum*(s[i][j]!='1')+(j<p);
			f[i][j]=(f[i][j]+(long long)f[i-1][j]*sum)%mod;
		}
		for(int j=1;j<=n;j++)
		{
			f0[j]=(!f0[j]&&s[i][j]=='0')?i:f0[j];
			f1[j]=(s[i][j]=='1')?i:f1[j];
		}
	}
	int ans=0;
	for(int i=n,v=1;v&&i>=0;i--)
	{
		ans=(ans+(long long)f[n][i]*v)%mod;
		v=(long long)v*max(0,(f0[i]?f0[i]:n+1)-f1[i])%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5612kb

input:

2
??
??

output:

14

result:

ok 1 number(s): "14"

Test #2:

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

input:

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

output:

3144

result:

ok 1 number(s): "3144"

Test #3:

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

input:

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

output:

361458985

result:

ok 1 number(s): "361458985"

Test #4:

score: 0
Accepted
time: 37ms
memory: 47864kb

input:

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

output:

56427841

result:

ok 1 number(s): "56427841"

Test #5:

score: 0
Accepted
time: 48ms
memory: 47800kb

input:

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

output:

145247225

result:

ok 1 number(s): "145247225"

Test #6:

score: 0
Accepted
time: 62ms
memory: 47712kb

input:

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

output:

925248762

result:

ok 1 number(s): "925248762"

Test #7:

score: 0
Accepted
time: 75ms
memory: 47800kb

input:

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

output:

845505610

result:

ok 1 number(s): "845505610"

Test #8:

score: 0
Accepted
time: 80ms
memory: 47720kb

input:

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

output:

123028256

result:

ok 1 number(s): "123028256"

Test #9:

score: 0
Accepted
time: 76ms
memory: 47792kb

input:

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

output:

242286033

result:

ok 1 number(s): "242286033"

Test #10:

score: 0
Accepted
time: 72ms
memory: 47776kb

input:

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

output:

448817936

result:

ok 1 number(s): "448817936"

Test #11:

score: 0
Accepted
time: 71ms
memory: 47760kb

input:

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

output:

621258555

result:

ok 1 number(s): "621258555"

Test #12:

score: 0
Accepted
time: 63ms
memory: 47772kb

input:

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

output:

552098298

result:

ok 1 number(s): "552098298"

Test #13:

score: 0
Accepted
time: 80ms
memory: 47764kb

input:

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

output:

190431651

result:

ok 1 number(s): "190431651"

Test #14:

score: 0
Accepted
time: 70ms
memory: 47740kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 72ms
memory: 47784kb

input:

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

output:

641634738

result:

ok 1 number(s): "641634738"

Test #16:

score: 0
Accepted
time: 75ms
memory: 47772kb

input:

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

output:

434138343

result:

ok 1 number(s): "434138343"

Test #17:

score: 0
Accepted
time: 68ms
memory: 47796kb

input:

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

output:

70334815

result:

ok 1 number(s): "70334815"

Test #18:

score: 0
Accepted
time: 68ms
memory: 47732kb

input:

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

output:

26692788

result:

ok 1 number(s): "26692788"

Test #19:

score: 0
Accepted
time: 68ms
memory: 47788kb

input:

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

output:

513359183

result:

ok 1 number(s): "513359183"

Test #20:

score: 0
Accepted
time: 65ms
memory: 47700kb

input:

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

output:

144382583

result:

ok 1 number(s): "144382583"

Test #21:

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

input:

1
0

output:

1

result:

ok 1 number(s): "1"

Test #22:

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

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

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

input:

2
10
01

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 67ms
memory: 47772kb

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: 59ms
memory: 47796kb

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: 37ms
memory: 47800kb

input:

3000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Test #27:

score: 0
Accepted
time: 48ms
memory: 47800kb

input:

3000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Extra Test:

score: 0
Extra Test Passed