1415. Friends

单点时限: 2.0 sec

内存限制: 256 MB

You want to plan a big birthday party with your friends. On planning you notice that you have to do a lot of operations with sets of friends. There is one group which consist of Arthur, Biene and Clemens. Then there is a group of friends you know from snowboarding which consists of Daniel, Ernst, Frida and Gustav. If you want to invite them both, the resulting party group consists of g1 + g2 (the result is the union of both groups). Then you can compute the intersection of the two groups g1 * g2, which consists of the empty set. Maybe you want to invite a group g1, but excluding all members of an other group g2, which is written as g1 - g2.

Intersection (*) has precedence over union (+) and set difference (-). All operations are left associative, which means that in A op1 B op2 C you first have to evaluate A op1 B (provided op1 and op2 have equal precedence).

输入格式

The input consists of one or more lines. Each line contains one expression that you have to evaluate. Expressions are syntactically correct and only consist of the characters:

  • ’{‘ and ‘}’

  • the elements ‘A’ to ‘Z’ meaning friend Arthur to Zora.

  • the operations ‘+’, ‘-‘ and ‘*’

  • ’(‘ and ‘)’ for grouping operations

  • the newline character ‘\n’ marking the end of an expression.

A line is never longer than 255 characters.

输出格式

Output the resulting set in curly braces ‘{‘ and ‘}’, each on a line of its own. Print elements of sets sorted alphabetically.

样例

Input
{ABC}
{ABC}+{DEFG}+{Z}+{}
{ABE}*{ABCD}
{ABCD}-{CZ}
{ABC}+{CDE}*{CEZ}
({ABC}+{CDE})*{CEZ}
Output
{ABC}
{ABCDEFGZ}
{AB}
{ABD}
{ABCE}
{CE}

1 人解决,3 人已尝试。

1 份提交通过,共有 3 份提交。

9.9 EMB 奖励。

创建: 16 年,9 月前.

修改: 6 年,8 月前.

最后提交: 13 年,9 月前.

来源: Ulm Local 1999

题目标签