2574. Principles of Compiler

单点时限: 2.0 sec

内存限制: 256 MB

After learnt the Principles of Compiler,partychen thought that he can solve a simple expression problem.So he give you strings of less than 100 characters which strictly adhere to the following grammar (given in EBNF):

A:= ‘(‘ B’)’|’x’.

B:=AC.

C:={‘+’A}.

Can you solve them too?

输入格式

The first line of input gives the number of cases, N(1 ≤ N ≤ 100). N test cases follow.

The next N lines will each contain a string as described above.

输出格式

For each test case,if the expression is adapt to the EBNF above output “Good”,else output “Bad”.

样例

Input
3
(x)
(x+(x+x))
()(x)
Output
Good
Good
Bad

72 人解决,168 人已尝试。

90 份提交通过,共有 856 份提交。

5.5 EMB 奖励。

创建: 15 年前.

修改: 6 年,8 月前.

最后提交: 18 小时前.

来源: 2009 华东师范大学 研究生复试

题目标签