304625: CF883E. Field of Wonders
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Field of Wonders
题意翻译
Polycarpus参加了一个电视节目,节目的参与者的任务是尽快猜出一个完全未知的单词。 节目中,每位参与者会轮流说出一个字母,主持人会回答这个词中是否有这样的字母。如果有,那么主持人就会透露单词中所有与它相同的字母。例如,如果未知的单词是 $"abacaba"$,参与者说出了字母 $a$,主持人就会展示单词中所有字母 $a$ 的下标 $:1,3,5,7$(下标从$1$开始,从左至右)。 Polycarpus知道 $m$ 个单词,这 $m$ 个单词的长度与未知单词的长度相同。他也知道,这个未知的单词,是这些 $m$ 个单词中的一个。 节目已经进行了若干轮,未知单词的一些字母(可能没有)已经知道了,且Polycarpus能够准确地说出目前已知的字母。 现在该Polycarpus说字母了。他想说出一个字母,使得主持人一定会透露至少一个字母。但是,Polycarpus无法分辨这些已经知道的字母。你的任务是帮助Polycarpus,找出他能说的字母,使得节目主持人一定会透露至少一个未知的字母。 ### 输入格式 第一行一个数字 $n(1 \le n \le 50)$,为未知单词的长度。 接下来一行,是目前已知的单词(对于该单词的每一个字母,\*代表该字母未知,否则代表已经被猜出的字母,数据保证一定有字母未知)。 第三行一个数字 $m(1 \le m \le 1000)$,其含义如题意。 接下来 $m$ 行,每行有一个单词为Polycarpus已知的单词,它们的长度都为 $n$。 ### 输出格式 输出只有一行一个数字,代表Polycarpus可以说的字母数,此数可以为 $0$。题目描述
Polycarpus takes part in the "Field of Wonders" TV show. The participants of the show have to guess a hidden word as fast as possible. Initially all the letters of the word are hidden. The game consists of several turns. At each turn the participant tells a letter and the TV show host responds if there is such letter in the word or not. If there is such letter then the host reveals all such letters. For example, if the hidden word is "abacaba" and the player tells the letter "a", the host will reveal letters at all positions, occupied by "a": $ 1 $ , $ 3 $ , $ 5 $ and $ 7 $ (positions are numbered from left to right starting from 1). Polycarpus knows $ m $ words of exactly the same length as the hidden word. The hidden word is also known to him and appears as one of these $ m $ words. At current moment a number of turns have already been made and some letters (possibly zero) of the hidden word are already revealed. Previously Polycarp has told exactly the letters which are currently revealed. It is Polycarpus' turn. He wants to tell a letter in such a way, that the TV show host will assuredly reveal at least one more letter. Polycarpus cannot tell the letters, which are already revealed. Your task is to help Polycarpus and find out the number of letters he can tell so that the show host will assuredly reveal at least one of the remaining letters.输入输出格式
输入格式
The first line contains one integer $ n $ ( $ 1<=n<=50 $ ) — the length of the hidden word. The following line describes already revealed letters. It contains the string of length $ n $ , which consists of lowercase Latin letters and symbols "\*". If there is a letter at some position, then this letter was already revealed. If the position contains symbol "\*", then the letter at this position has not been revealed yet. It is guaranteed, that at least one letter is still closed. The third line contains an integer $ m $ ( $ 1<=m<=1000 $ ) — the number of words of length $ n $ , which Polycarpus knows. The following $ m $ lines contain the words themselves — $ n $ -letter strings of lowercase Latin letters. All words are distinct. It is guaranteed that the hidden word appears as one of the given $ m $ words. Before the current move Polycarp has told exactly the letters which are currently revealed.
输出格式
Output the single integer — the number of letters Polycarpus can tell so that the TV show host definitely reveals at least one more letter. It is possible that this number is zero.
输入输出样例
输入样例 #1
4
a**d
2
abcd
acbd
输出样例 #1
2
输入样例 #2
5
lo*er
2
lover
loser
输出样例 #2
0
输入样例 #3
3
a*a
2
aaa
aba
输出样例 #3
1