304746: CF906A. Shockers
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Shockers
题意翻译
## 题目描述 ```Valentin```参加了一个名为“震惊者(Shockers)”的节目。节目规则很简单:节目团队选择一个字母,但```Valentin```不知道是什么。```Valentin```需要做一个很短的演讲,在演讲中他每说到这个字母,都会受到电击。他可以猜测节目组选的是哪个字母,但是如果他猜错了,也会受到电击。当```Valentin```正确猜出所选字母时,流程结束。 ```Valentin```记性不好,记不住之前每次电击的时间,所以他有可能会后知后觉,在已经能判断选定字母是什么的时候还猜错了,于是被电。这种电击成为“过量电击”,它是本可以避免的。简单来说,过量电击是```Valentin```在所选字母可以唯一确定之后挨的电击。 ## 输入输出格式 ### 输入格式: 第一行一个整数nnn (1≤n≤105)(1\le n \le 10^5 )(1≤n≤105),表示```Valentin```做出的行动,包括演讲以及猜测等。 下面nnn行内容,为他行动的描述,每行描述一个行动。每个行动可以是以下三种类型之一: 1. 他发表了一段演讲,且没有受到电击。此行动由字符串".w"(不带引号)描述,其中"." 是一个点(ASCII码46),"w"代表他说的话。 2. ```Valentin```发表了一段演讲,而且被电了。此行动由字符串"!w"(不带引号)描述,其中"!"是感叹号(ASCII码33),"w"代表他说的话。 3. 他对所选字母做了猜测。此操作由字符串"? s"(不带引号)描述,其中"?"是问号(ASCII码63),"s"是一个小写英文字母,代表```Valentin```所作的猜测。 他发表的演讲中只有小写英文字母。 保证最后一个行动是他对所选字母的猜测。 此外,保证```Valentin```在最后一次行动之前所做出的任何猜测全都是错的。(此处省略一句废话) ### 输出格式: 输出一个整数,即为过量点击的次数。 ## 样例说明 在样例1中:第一个行动之后,我们已经能看出所选的字母一定是a,b,c中的一个。第二个行动又告诉我们它不是a。```Valentin```又在演讲中说到了“b”这个词,但并没有被电,所以选定字母肯定是c。他后来又讲出了"cd"这个词导致被电,这很明显是一次过量点击。 在样例2中:在前两次电击后,我们可以得出所选字母肯定是e和o中的一个。于是```Valentin```又试了几次,在他说出"o"之后并没有被电,所以所选的字母是e。但他还问了d和h,导致自己被电,所以答案为2。 在样例3中:```Valentin```打出完美操作,没有受到过量电击。题目描述
Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electric shock. He can make guesses which letter is selected, but for each incorrect guess he receives an electric shock too. The show ends when Valentin guesses the selected letter correctly. Valentin can't keep in mind everything, so he could guess the selected letter much later than it can be uniquely determined and get excessive electric shocks. Excessive electric shocks are those which Valentin got after the moment the selected letter can be uniquely determined. You should find out the number of excessive electric shocks.输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1<=n<=10^{5} $ ) — the number of actions Valentin did. The next $ n $ lines contain descriptions of his actions, each line contains description of one action. Each action can be of one of three types: 1. Valentin pronounced some word and didn't get an electric shock. This action is described by the string ". w" (without quotes), in which "." is a dot (ASCII-code 46), and $ w $ is the word that Valentin said. 2. Valentin pronounced some word and got an electric shock. This action is described by the string "! w" (without quotes), in which "!" is an exclamation mark (ASCII-code 33), and $ w $ is the word that Valentin said. 3. Valentin made a guess about the selected letter. This action is described by the string "? s" (without quotes), in which "?" is a question mark (ASCII-code 63), and $ s $ is the guess — a lowercase English letter. All words consist only of lowercase English letters. The total length of all words does not exceed $ 10^{5} $ . It is guaranteed that last action is a guess about the selected letter. Also, it is guaranteed that Valentin didn't make correct guesses about the selected letter before the last action. Moreover, it's guaranteed that if Valentin got an electric shock after pronouncing some word, then it contains the selected letter; and also if Valentin didn't get an electric shock after pronouncing some word, then it does not contain the selected letter.
输出格式
Output a single integer — the number of electric shocks that Valentin could have avoided if he had told the selected letter just after it became uniquely determined.
输入输出样例
输入样例 #1
5
! abc
. ad
. b
! cd
? c
输出样例 #1
1
输入样例 #2
8
! hello
! codeforces
? c
. o
? d
? h
. l
? e
输出样例 #2
2
输入样例 #3
7
! ababahalamaha
? a
? b
? a
? b
? a
? h
输出样例 #3
0