Two Bracket Sequences

题意翻译

给出两个括号串$s,t$($s,t$ 不一定合法),它们仅由左括号`(`和右括号`)`组成 你需要构造一个字符串 $f$,使得 $s,t$ 都是 $f$ 的子串(不一定是连续子串),并满足:字符串 $f$ 合法且 $|f|$($f$的长度)尽可能小 定义合法括号串: - `()`是合法括号串 - 若 $S$ 是合法括号串,则 $(S)$ 也是合法括号串 - 若 $A$ 和 $B$ 都是合法括号串,则 $AB$ 也是合法括号串 ## 输入格式 第一行一个字符串 $s$。 第二行一个字符串 $t$。 ## 输出格式 一行一个字符串,表示题目描述中的字符串 $f$。 ### 数据范围 $|s|,|t| \le 200$。 感谢 @_Wolverine 提供的翻译

题目描述

You are given two bracket sequences (not necessarily regular) $ s $ and $ t $ consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous). Recall what is the regular bracket sequence: - () is the regular bracket sequence; - if $ S $ is the regular bracket sequence, then ( $ S $ ) is a regular bracket sequence; - if $ S $ and $ T $ regular bracket sequences, then $ ST $ (concatenation of $ S $ and $ T $ ) is a regular bracket sequence. Recall that the subsequence of the string $ s $ is such string $ t $ that can be obtained from $ s $ by removing some (possibly, zero) amount of characters. For example, "coder", "force", "cf" and "cores" are subsequences of "codeforces", but "fed" and "z" are not.

输入输出格式

输入格式


The first line of the input contains one bracket sequence $ s $ consisting of no more than $ 200 $ characters '(' and ')'. The second line of the input contains one bracket sequence $ t $ consisting of no more than $ 200 $ characters '(' and ')'.

输出格式


Print one line — the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous). If there are several answers, you can print any.

输入输出样例

输入样例 #1

(())(()
()))()

输出样例 #1

(())()()

输入样例 #2

)
((

输出样例 #2

(())

输入样例 #3

)
)))

输出样例 #3

((()))

输入样例 #4

())
(()(()(()(

输出样例 #4

(()()()(()()))