QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#460658#8552. SticksSATSKYAC ✓253ms153516kbC++202.4kb2024-07-01 23:49:422024-07-01 23:49:43

Judging History

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

  • [2024-07-01 23:49:43]
  • 评测
  • 测评结果:AC
  • 用时:253ms
  • 内存:153516kb
  • [2024-07-01 23:49:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;using ld=long double;using pii=pair<int,int>;
const int M=998244353,N=3e3+10;const ll inf=1e17;const double eps=1e-10;
int dp[N][N][2][2];//row/colume/[lu grid]colored(bas 1)/[lu grid]if upper belonging
void add(int&a,int b){a+=b;if(a>=M)a-=M;}
struct S
{	
	int n;ll res=0;
	vector<string>mat;
	vector<int>u0,l0,d1,r1;
	void ini()
	{
		dp[0][0][0][1]=1;cin>>n;mat.resize(n+1);mat[0]="0";
		string s;for(int i=1;i<=n;i++)mat[0]+='1',cin>>s,mat[i]="1"+s;
		u0.resize(n+1,n+1);l0=u0;d1.resize(n+1,0);r1=d1;		
	}
	void solve()
	{
		for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)
		{
			char c=mat[i][j];		
			if(j)//move right
			{//row/colume/[lu grid]colored(bas 1)/[lu grid]if upper belonging
				if(c!='1')
				{
					int &a=dp[i][j][0][1];ll v=max(min(u0[j],i)-d1[j],0);//W _ hang right
					add(a,v*dp[i][j-1][0][0]%M);//W |
					add(a,v*dp[i][j-1][0][1]%M);//W _
					add(a,v*dp[i][j-1][1][0]%M);//B |
					add(a,v*dp[i][j-1][1][1]%M);//B _
				}
				if(c!='0'&&u0[j]==n+1)
				{
					int &b=dp[i][j][1][1];//B _ hang right
					add(b,dp[i][j-1][0][0]);//W |
					add(b,dp[i][j-1][0][1]);//W _
					add(b,dp[i][j-1][1][0]);//B |
					add(b,dp[i][j-1][1][1]);//B _
				}
			}
			if(i)//move down
			{//row/colume/[lu grid]colored(bas 1)/[lu grid]if upper belonging
				if(c!='1')
				{
					int &a=dp[i][j][0][0];ll v=max(min(l0[i],j)-r1[i],0);//W | hang down
					add(a,v*dp[i-1][j][0][0]%M);//W |
					//add(a,dp[i-1][j][0][1]);//W _
					add(a,v*dp[i-1][j][1][0]%M);//B |
					//add(a,dp[i-1][j][1][1]);//B _
				}								
				if(c!='0'&&l0[i]==n+1)
				{
					int &b=dp[i][j][1][0];//B | hang down
					add(b,dp[i-1][j][0][0]);//W |
					add(b,dp[i-1][j][0][1]);//W _
					add(b,dp[i-1][j][1][0]);//B |
					//add(b,dp[i-1][j][1][1]);//B _
				}				
			}	
			if(i||j)
			{
				if(c=='0')l0[i]=min(l0[i],j),u0[j]=min(u0[j],i);
				if(c=='1')r1[i]=max(r1[i],j),d1[j]=max(d1[j],i);
			}
			//cout<<i<<","<<j<<":";for(int e=0;e<2;e++)for(int f=0;f<2;f++)cout<<dp[i][j][e][f]<<"|";cout<<'\n';
		}
		int res=0;for(int e=0;e<2;e++)for(int f=0;f<2;f++)add(res,dp[n][n][e][f]);cout<<res<<'\n';
	}
};
void precal(){}
int main()
{
	//freopen("1.in","r",stdin);
	//cout<<fixed<<setprecision(12);
	ios::sync_with_stdio(0);cin.tie(0);precal();
	int t=1;//cin>>t;
	//clock_t a=clock();
	while(t--){S SS;SS.ini();SS.solve();}
	//cout<<"Time:"<<double(clock()-a)<<'\n';
}

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

詳細信息

Test #1:

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

input:

2
??
??

output:

14

result:

ok 1 number(s): "14"

Test #2:

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

input:

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

output:

3144

result:

ok 1 number(s): "3144"

Test #3:

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

input:

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

output:

361458985

result:

ok 1 number(s): "361458985"

Test #4:

score: 0
Accepted
time: 133ms
memory: 153392kb

input:

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

output:

56427841

result:

ok 1 number(s): "56427841"

Test #5:

score: 0
Accepted
time: 152ms
memory: 153320kb

input:

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

output:

145247225

result:

ok 1 number(s): "145247225"

Test #6:

score: 0
Accepted
time: 215ms
memory: 153488kb

input:

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

output:

925248762

result:

ok 1 number(s): "925248762"

Test #7:

score: 0
Accepted
time: 235ms
memory: 153516kb

input:

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

output:

845505610

result:

ok 1 number(s): "845505610"

Test #8:

score: 0
Accepted
time: 226ms
memory: 153388kb

input:

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

output:

123028256

result:

ok 1 number(s): "123028256"

Test #9:

score: 0
Accepted
time: 203ms
memory: 153292kb

input:

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

output:

242286033

result:

ok 1 number(s): "242286033"

Test #10:

score: 0
Accepted
time: 253ms
memory: 153316kb

input:

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

output:

448817936

result:

ok 1 number(s): "448817936"

Test #11:

score: 0
Accepted
time: 235ms
memory: 153308kb

input:

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

output:

621258555

result:

ok 1 number(s): "621258555"

Test #12:

score: 0
Accepted
time: 201ms
memory: 153312kb

input:

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

output:

552098298

result:

ok 1 number(s): "552098298"

Test #13:

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

input:

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

output:

190431651

result:

ok 1 number(s): "190431651"

Test #14:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #15:

score: 0
Accepted
time: 233ms
memory: 153464kb

input:

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

output:

641634738

result:

ok 1 number(s): "641634738"

Test #16:

score: 0
Accepted
time: 250ms
memory: 153236kb

input:

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

output:

434138343

result:

ok 1 number(s): "434138343"

Test #17:

score: 0
Accepted
time: 229ms
memory: 153360kb

input:

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

output:

70334815

result:

ok 1 number(s): "70334815"

Test #18:

score: 0
Accepted
time: 207ms
memory: 153396kb

input:

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

output:

26692788

result:

ok 1 number(s): "26692788"

Test #19:

score: 0
Accepted
time: 207ms
memory: 153392kb

input:

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

output:

513359183

result:

ok 1 number(s): "513359183"

Test #20:

score: 0
Accepted
time: 223ms
memory: 153176kb

input:

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

output:

144382583

result:

ok 1 number(s): "144382583"

Test #21:

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

input:

1
0

output:

1

result:

ok 1 number(s): "1"

Test #22:

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

input:

1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

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

input:

2
10
01

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 142ms
memory: 153388kb

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: 121ms
memory: 153244kb

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: 74ms
memory: 153316kb

input:

3000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Test #27:

score: 0
Accepted
time: 104ms
memory: 153308kb

input:

3000
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1

result:

ok 1 number(s): "1"

Extra Test:

score: 0
Extra Test Passed