题解:P6873 [COCI 2013/2014 #6] FONT
xtzhangziche · · 题解
题目传送门
题目大意
现在给你
思路
数据很小,直接用搜索。
枚举选或不选,到最后看看是否能组成包含所有小写英文字母的字符串。
Code
#include<bits/stdc++.h>
using namespace std;
int n,a[26],t;
string s;
void dfs(int x,int y){
if(x==n) {if(y==(1<<26)-1) t++;return;}
dfs(x+1,y),dfs(x+1,y|a[x]);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
for(int i=0;i<n;i++)
{
cin>>s;
int len=s.size();
for(int j=0;j<len;j++)
a[i]|=(1<<(s[j]-97));
}
dfs(0,0),cout<<t;
return 0;
}