题解:P6873 [COCI2013-2014#6] FONT
DeadDreamX · · 题解
题目传送门 \
首先,我们发现
#include<bits/stdc++.h>
using namespace std;
const int N=30,ed=67108863;//ed为2^26-1
int n,a[N],cnt;
void dfs(int x,int tot,int st)
{
if(x==n+1)
{
if(st==ed) cnt++;
return ;
}
dfs(x+1,tot,st);
dfs(x+1,tot+1,st|a[x]);
return ;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
string s="";
char ch=0;
while(!(ch>='a' and ch<='z')) ch=getchar();
while(ch>='a' and ch<='z')
{
s+=ch;
ch=getchar();
}
for(int j=0;j<26;j++)
{
bool flag=0;
for(int k=0;k<s.size();k++)
flag|=(s[k]-'a'==j);
if(flag) a[i]+=(1<<j);
}
}
dfs(1,0,0);
cout<<cnt;
return 0;
}