

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
あなたは 本の鍵 を持っています。
このうち何本かの鍵は正しい鍵で、それ以外はダミーの鍵です。
また、鍵を何本でも挿し込める ドアX があり、この ドアX は正しい鍵を 本以上挿し込んだ時、またその時に限って開きます。
あなたはこれらの鍵に対して 回のテストを行いました。このうち 回目のテストの内容は次の通りです。
- 本の鍵 を ドアX に挿し込む。
- テスト結果はひとつの英文字 で表現される。
-
o
のとき 回目のテストでドアが開いたことを表す。 -
x
のとき 回目のテストでドアが開かなかったことを表す。
-
各鍵が正しいかダミーかの組み合わせは 通り考えられますが、このうちどのテスト結果にも矛盾しない組み合わせの個数を求めてください。
ただし、与えられるテスト結果が誤っており上記の条件を満たす組み合わせが存在しない場合もあります。その場合は 通りと解答してください。
制約
- は整数
- ならば
- は
o
またはx
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを整数として出力せよ。
入力例 1Copy
3 2 2 3 1 2 3 o 2 2 3 x
出力例 1Copy
2
この入力では鍵が 本あり、テストは 回行われました。
また、 ドアX を開くのに必要な正しい鍵の本数は 本です。
- 回目のテストでは鍵 を使い、その結果 ドアX は開きました。
- 回目のテストでは鍵 を使い、その結果 ドアX は開きませんした。
各鍵が正しいかダミーかの組み合わせであって、どのテスト結果にも矛盾しないものは以下の 通りです。
- 鍵 は本物、鍵 はダミー、鍵 は本物である。
- 鍵 は本物、鍵 は本物、鍵 はダミーである。
入力例 2Copy
4 5 3 3 1 2 3 o 3 2 3 4 o 3 3 4 1 o 3 4 1 2 o 4 1 2 3 4 x
出力例 2Copy
0
問題文中でも述べた通り、答えが 通りである場合もあります。
入力例 3Copy
11 4 9 10 1 2 3 4 5 6 7 8 9 10 o 11 1 2 3 4 5 6 7 8 9 10 11 o 10 11 10 9 8 7 6 5 4 3 2 x 10 11 9 1 4 3 7 5 6 2 10 x
出力例 3Copy
8
Score : points
Problem Statement
You have keys numbered .
Some of these are real keys, while the others are dummies.
There is a door, Door X, into which you can insert any number of keys. Door X will open if and only if at least real keys are inserted.
You have conducted tests on these keys. The -th test went as follows:
- You inserted keys into Door X.
- The test result is represented by a single English letter .
-
o
means that Door X opened in the -th test. -
x
means that Door X did not open in the -th test.
-
There are possible combinations of which keys are real and which are dummies. Among these, find the number of combinations that do not contradict any of the test results.
It is possible that the given test results are incorrect and no combination satisfies the conditions. In such a case, report .
Constraints
- , , , , and are integers.
- if .
- is
o
orx
.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1Copy
3 2 2 3 1 2 3 o 2 2 3 x
Sample Output 1Copy
2
In this input, there are three keys and two tests were conducted.
Two correct keys are required to open Door X.
- In the first test, keys were used, and Door X opened.
- In the second test, keys were used, and Door X did not open.
There are two combinations of which keys are real and which are dummies that do not contradict any of the test results:
- Key is real, key is a dummy, and key is real.
- Key is real, key is real, and key is a dummy.
Sample Input 2Copy
4 5 3 3 1 2 3 o 3 2 3 4 o 3 3 4 1 o 3 4 1 2 o 4 1 2 3 4 x
Sample Output 2Copy
0
As mentioned in the problem statement, the answer may be .
Sample Input 3Copy
11 4 9 10 1 2 3 4 5 6 7 8 9 10 o 11 1 2 3 4 5 6 7 8 9 10 11 o 10 11 10 9 8 7 6 5 4 3 2 x 10 11 9 1 4 3 7 5 6 2 10 x
Sample Output 3Copy
8