P25367 [AtCoder] Short Coding
提高+
题目描述

Problem Description

The Short Coding Contest "Short King" is a contest where participants compete to solve problems with the shortest code possible. Before participating in the Short King, let's warm up with a programming language called "!-! Language".

  • A program in the !-! Language is described as a string of unary operators - and ! that can appear zero or more times.
  • The program receives exactly one integer input between -256 and 256, applies the unary operators to the input value from the end to the beginning, and outputs the final value.
  • Each unary operator performs the following calculations:
  • -: Inverts the sign of the value. For example, 29 becomes -29, -89 becomes 89, and 0 remains 0.
  • !: If the value is 0, it becomes 1; otherwise, it becomes 0. For example, 29 becomes 0, -89 becomes 0, and 0 becomes 1.

For example, if the program !-!- is given an input of 5, it operates as follows:

  • The first operator from the end is -, changing 5 to -5.
  • The second operator from the end is !, changing -5 to 0.
  • The third operator from the end is -, changing 0 to 0.
  • The fourth operator from the end is !, changing 0 to 1.
  • The program outputs 1 and terminates.

Given a program in the !-! Language, output the shortest !-! Language program that produces the same result for all integer inputs between -256 and 256.

Input Format

The input is given from the standard input in the following format:

$ S $

  • The first line contains a string $S\ (1\ ≦\ |S|\ ≦\ 256)$ representing the code to be shortened. It is guaranteed that $ S $ consists only of the characters - and !.

Output Format

Output the shortest program that produces the same result as the given program in one line. If there are multiple shortest programs, you may output any one of them. Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

---!!-!--

Sample Output #1

-!

Sample Input #2

!!

Sample Output #2

!!

Sample Input #3

----------

Sample Output #3

(empty string)

Notes/Hints

Sample Explanation 3

An empty string is also a valid program. If the answer is an empty string, ensure a newline at the end of the output.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
---!!-!--
样例输出
-!