跳到正文

题解

题解:P6873 [COCI 2013/2014 #6] FONT

xtzhangziche约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P6873

版本

  1. v1当前

题目传送门

题目大意

现在给你 NN 个单词,请问这些单词最多能组成多少个包含所有小写英文字母的字符串。

思路

数据很小,直接用搜索。

枚举选或不选,到最后看看是否能组成包含所有小写英文字母的字符串。

Code

C++
#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;
}
原文