Score : $400$ points
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}$:
AND
, and $y_i=y_{i-1} \lor x_i$ if $S_i$ is OR
.Here, $a \land b$ and $a \lor b$ are logical operators.
AND
or OR
.Input is given from Standard Input in the following format:
$N$ $S_1$ $\vdots$ $S_N$
Print the answer.
2 AND OR
5
For example, if $(x_0,x_1,x_2)=(\text{True},\text{False},\text{True})$, we have $y_2 = \text{True}$, as follows:
All of the five tuples $(x_0,x_1,x_2)$ resulting in $y_2 = \text{True}$ are shown below:
5 OR OR OR OR OR
63
All tuples except the one filled entirely with $\text{False}$ result in $y_5 = \text{True}$.