http://acm.hdu.edu.cn/showproblem.php?pid=5965
枚举每一列的雷的数量,只有012三种情况,1的情况有2种方式
那么我们就可以根据前2列的情况来推出第三列雷的数量的情况
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const int maxn=1e4+10;
const int mod=1e8+7;
int T;
char a[maxn];
int b[maxn];
int dp[maxn];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",a);
int len=strlen(a);
for(int i=0;i<len;i++)
{
b[i+1]=a[i]-'0';
}
ll ans=0;
for(int i=0;i<=min(2,b[1]);i++)
{
memset(dp,0,sizeof(dp));
dp[1]=i;
bool flag=true;
ll res=1;
//cout<<i<<' ';
for(int j=2;j<=len;j++)
{
dp[j]=b[j-1]-dp[j-1]-dp[j-2];
//cout<<dp[j]<<' ';
if(dp[j]<0||dp[j]>2)
{
flag=false;
break;
}
if(dp[j]==1)res=res*2%mod;
}
if(dp[1]==1)res=res*2%mod;
if(dp[len]+dp[len-1]!=b[len])flag=false;
if(flag)ans=(ans+res)%mod;
}
printf("%lld\n",ans);
}
return 0;
}