301362: CF255B. Code Parsing
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Code Parsing
题意翻译
钦定一个由`X`和`Y`组成的字符串。 有两个操作 1. 出现`YX`时交换他们 2. 出现`XY`时删除他们 你可以不断地做这些操作(优先做操作1 当你不能做任何操作时,输出此时的字符串。 @我不是箭毒蛙题目描述
Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string $ s $ , consisting of characters "x" and "y", and uses two following operations at runtime: 1. Find two consecutive characters in the string, such that the first of them equals "y", and the second one equals "x" and swap them. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string. 2. Find in the string two consecutive characters, such that the first of them equals "x" and the second one equals "y". Remove these characters from the string. If there are several suitable pairs of characters, we choose the pair of characters that is located closer to the beginning of the string. The input for the new algorithm is string $ s $ , and the algorithm works as follows: 1. If you can apply at least one of the described operations to the string, go to step 2 of the algorithm. Otherwise, stop executing the algorithm and print the current string. 2. If you can apply operation 1, then apply it. Otherwise, apply operation 2. After you apply the operation, go to step 1 of the algorithm. Now Vitaly wonders, what is going to be printed as the result of the algorithm's work, if the input receives string $ s $ .输入输出格式
输入格式
The first line contains a non-empty string $ s $ . It is guaranteed that the string only consists of characters "x" and "y". It is guaranteed that the string consists of at most $ 10^{6} $ characters. It is guaranteed that as the result of the algorithm's execution won't be an empty string.
输出格式
In the only line print the string that is printed as the result of the algorithm's work, if the input of the algorithm input receives string $ s $ .
输入输出样例
输入样例 #1
x
输出样例 #1
x
输入样例 #2
yxyxy
输出样例 #2
y
输入样例 #3
xxxxxy
输出样例 #3
xxxx