#include<stdio.h>#define mod 1000000007#include<string.h>#include<algorithm>using namespace std;int dp[1111][1111];char str[6666];int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); scanf(" %s",str+1); memset(dp,0,sizeof(dp)); for(int i=0; i<=n; i++) for(int j=0; j<=n; j++) { if(i||j) { if(str[i+j]=='W') { if(i%2==1) dp[i][j]+=dp[i-1][j]%mod; if(j%2==1) dp[i][j]+=dp[i][j-1]%mod; } else if(str[i+j]=='B') { if(i%2==0&&i) dp[i][j]+=dp[i-1][j]%mod; if(j%2==0&&j) dp[i][j]+=dp[i][j-1]%mod; } } else dp[i][j]=1; } PRintf("%d/n",dp[n][n]%mod); }}
新闻热点
疑难解答