RT
比赛的时候本来想写个爆搜的。但是爆搜写挂了。。。不知道这个爆搜挂在什么地方。求大佬火眼金睛
#include<bits/stdc++.h>
using namespace std;
int n;
const int N=5e5+5;
int a[N],b[N],c[N];
int ans;
void dfs(int x,int type){
b[x]=type;
if(x==n){
int tot=0;
for(int i=1;i<=n;i++)
if(b[i]) c[++tot]=a[i];
if(tot&1) return ;
bool f=true;
for(int i=1;i<=tot/2;i++) f&=(c[i*2]==c[i*2-1]);
for(int i=1;i<tot/2;i++) f&=(c[i*2]!=c[i*2+1]);
if(f) ans++;
return ;
}
dfs(x+1,0);
dfs(x+1,1);
}
int main(){
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
dfs(1,0);
dfs(1,1);
cout<<ans;
return 0;
}