AtCoder Beginner Contest 189
翻译中…
Problem Statement
翻译中…
Given are $N$ strings $S_1,\ldots,S_N$, each of which is AND or OR.
翻译中…
Find the number of tuples of $N+1$ variables $(x_0,\ldots,x_N)$, where each element is $\text{True}$ or $\text{False}$, such that the following computation results in $y_N$ being $\text{True}$:
翻译中…
$y_0=x_0$;- for
$i\geq 1$,$y_i=y_{i-1} \land x_i$if$S_i$isAND, and$y_i=y_{i-1} \lor x_i$if$S_i$isOR.
翻译中…
Here, $a \land b$ and $a \lor b$ are logical operators.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 60$$S_i$isANDorOR.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S_1
\vdots
S_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
2
AND
OR
Output #1
5
For example, if $(x_0,x_1,x_2)=(\text{True},\text{False},\text{True})$, we have $y_2 = \text{True}$, as follows:
- $y_0=x_0=\text{True}$
- $y_1=y_0 \land x_1 = \text{True} \land \text{False}=\text{False}$
- $y_2=y_1 \lor x_2 = \text{False} \lor \text{True}=\text{True}$
All of the five tuples $(x_0,x_1,x_2)$ resulting in $y_2 = \text{True}$ are shown below:
- $(\text{True},\text{True},\text{True})$
- $(\text{True},\text{True},\text{False})$
- $(\text{True},\text{False},\text{True})$
- $(\text{False},\text{True},\text{True})$
- $(\text{False},\text{False},\text{True})$
Input #2
5
OR
OR
OR
OR
OR
Output #2
63
All tuples except the one filled entirely with $\text{False}$ result in $y_5 = \text{True}$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。