公共表达式消除 Common Subexpression Elimination

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=244&page=show_problem&problem=3371 [PDF](https://uva.onlinejudge.org/external/122/p12219.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12219/2fd7d1bfe7cdd84f4fab59d9609b86022f0314a6.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12219/1543b11ce67813a0ceb0a6699c5acf11b4cb0d3e.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12219/93e773e78504c5b7c91fb20bc3f3e268200cb643.png)

输入输出样例

输入样例 #1

3
this(is(a,tiny),tree)
a(b(f(a,a),b(f(a,a),f)),f(b(f(a,a),b(f(a,a),f)),f))
z(zz(zzzz(zz,z),zzzz(zz,z)),zzzz(zz(zzzz(zz,z),zzzz(zz,z)),z))

输出样例 #1

this(is(a,tiny),tree)
a(b(f(a,4),b(3,f)),f(2,6))
z(zz(zzzz(zz,z),3),zzzz(2,5))