比赛 2025.10.18 评测结果 AAAATMMMMM
题目名称 01数列 最终得分 40
用户昵称 会挽弯弓满月 运行时间 4.659 s
代码语言 C++ 内存使用 391.65 MiB
提交时间 2025-10-18 10:35:11
显示代码纯文本
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1010,mod=1e9+7;
ll n;
ll b[N],a[N];
ll ans;
void solve(ll i,ll j,string now){
    if(j>n){
        ans=(ans+1)%mod;
        return;
    }
    if(i>n){
        i=1;
        j++;
    }
    string s;
    if(b[i] == a[j]){
        s=now;
        s.push_back(b[i]+48);
        solve(i+1,j,s);
    }
	else{
        s=now;
        s.push_back(b[i]+48);
        solve(i+1,j,s);
        s=now;
        s.push_back(a[j]+48);
        solve(i+1,j,s);
    }
    return;
}
void dfs(ll x){
	if(x>n){
		solve(1,1,"");
		return;
	}
	a[x]=0;dfs(x+1);
	a[x]=1;dfs(x+1);
	return;
}
int main(){
	freopen("01.in","r",stdin);
	freopen("01.out","w",stdout);
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) scanf("%lld",&b[i]);
	dfs(1);
	printf("%lld",ans);
	return 0;
}