ACPC10C  Normalized Form
As you most probably know, any boolean expression can be expressed in either a disjunctive normal form or a conjunctive normal form. In a disjunctive normal form, a boolean expression is written as a disjunct (logical or) of oneor more subexpressions where each of these subexpressions is written in a conjunctive normal form. Similarly, an expression written in a conjunctive normal form is a conjunct (logical and) of subexpressions each written in a disjunctive normal form.
An AND/OR tree is a treelike graphicalrepresentation of boolean ex pressions written as either conjunctive or disjunctivenormal form. Since the subexpressions of a normalized form alternate in being either disjunctive or conjunctive forms, you’d expect the subtrees on an AND/OR tree to alternate in being AND or OR trees depending on the subtree’s depthlevel. The example upwards illustrates this observation for the boolean expression (A (B C)) (D E) where the trees in the 1st (topmost) and 3rd levels are ANDtrees.
Write a program that evaluates a given and/or tree.
Input
Your program will be tested on one or more test cases. Each test case is specified on exactly one line (which is no longer than 32,000 characters) of the form:
( E1 E2 . . . En )
where n > 0 and Ei is either T for true, F for false, or a subexpression using the same format.
The trees at the deepest level are ANDtrees. The last test case is followed by a dummy line made of ().
Output
For each test case, print the following line:
k. E
Where k is the test case number (starting at one,) and E is either true or false depending on the value of the expression in that test case.
Example
Input:
((F(TF))(TF))
(TFT)
((TFT)T)
()
Output:
1. false
2. false
3. true
hide comments
mahabir10:
20200919 06:16:37
very easy problem 

nadstratosfer:
20190713 08:38:59
Nice one. Ignore confusing comments; (T) is not a valid expression because both AND and OR need at least 2 operands. ((TFT)T) = ((1 or 0 or 1) and 1) = 1 and 1 = 1. 

vengatesh15:
20170125 09:51:21
AC in 1 go :) 

hodobox:
20161112 14:59:49
Nice :) 

GAURAV CHANDEL:
20160417 09:44:17
Lovely Problem.. 

Deepak Gupta:
20141201 17:39:40
Remember


(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
20120730 18:10:17
@Sachin Railhan: the answer for statement ((T)F) is true. 

Sachin Railhan:
20120730 10:35:19
What is the answer for statement ((T)F) ?


Hasan0540:
20120620 15:34:20
.... Last edit: 20120620 18:12:34 

manish sharma:
20111209 04:38:43
Last edit: 20120114 15:46:18 
Added by:  Omar ElAzazy 
Date:  20101227 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  ACPC 2010 