比赛 20241025 评测结果 AAAAAAAAAAAAAAAA
题目名称 Pair Programming 最终得分 100
用户昵称 健康铀 运行时间 0.513 s
代码语言 C++ 内存使用 11.84 MiB
提交时间 2024-10-25 11:33:47
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
char c[2000],d[2000];
int e[2001][2001];
int main(){
		freopen("prob2_gold_22open.in","r",stdin);
    freopen("prob2_gold_22open.out","w",stdout);
	int a,b,i,j,k,l;
	scanf("%d",&a);
	for (i=0;i<a;i++){
		scanf("%d%s%s",&b,c,d);
		e[0][0]=1;
		for (j=1;j<=b;j++){
			e[0][j]=1;
			e[j][0]=1;
		}
		for (k=1;k<=b;k++) for (l=1;l<=b;l++)
		if (c[k-1]=='0'&&d[l-1]=='0')
		e[k][l]=1;
		else if (c[k-1]=='0') 
		e[k][l]=(e[k][l-1]+(d[l-1]=='+'))%1000000007;
		else if (d[l-1]=='0')
		e[k][l]=(e[k-1][l]+(c[k-1]=='+'))%1000000007;
		else if (c[k-1]=='1'||d[l-1]=='1'||(c[k-1]>'0'+1&&c[k-1]<'9'+1&&d[l-1]>'0'-1&&d[l-1]<'9'+1)||(c[k-1]=='+'&&d[l-1]=='+')) 
		e[k][l]=((e[k-1][l]+e[k][l-1])%1000000007-e[k-1][l-1]+1000000007)%1000000007;
		else
		e[k][l]=(e[k-1][l]+e[k][l-1])%1000000007;
		printf("%d\n",e[b][b]);
	}
	return 0;
}