cswork / OA打开练习工作台

Jane StreetOA #1

Transform String

简单可在线判题

考点(AI 标注)单调栈与堆字符串

The string contains only A, B, C, and D. You may repeatedly delete any adjacent A/B pair (in either order) or C/D pair (in either order). Output any result that cannot be reduced further.

This site adds a standard input/output protocol.

输入格式

A single line with the string S; an empty string is given as an empty line.

输出格式

Output an irreducible string; if the result is empty, output an empty line.

样例 1

输入:

AB

输出:

样例 2

输入:

ABCD

输出:

样例 3

输入:

A

输出:

A