시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 64 MB | 437 | 201 | 170 | 51.672% |
An array in a certain programming language is defined in the following way:
Recently, you’ve noticed that the programming language does not throw an error if you do not place the appropriate number of spaces and new lines before or after the curly braces or the commas. Given the fact that you too mind the values being so „squished“ together, you’ve decided to get to work and modify the shape of the array in the following way:
The first line of input contains an array of characters S (1 ≤ |S| ≤ 1500), representing the array from the task.
The output must consist of the modified version of the array from the task.
{abc,ono,sto}
{ abc, ono, sto }
{}
{ }
{znakovi}
{ znakovi }
{a,b,{c,d},e,{}}
{ a, b, { c, d }, e, { } }
Clarification of the fourth example: In the beginning, there is no indentation, it is 0. After the first curly bracket, there is a new line and the indentation increases by 2 spaces.
After that, the word „a“ is printed, as well as the comma right after it, then the new line with the same indentation of 2 spaces. The same procedure is repeated for the word „b“.
The third value in the array is a new array (let’s call it array X). It begins with a curly bracket, so we need to print a new line and increase the indentation for 2 spaces. The indentation is now a total of 4 spaces. Using that indentation, we print the words „c“ and „d“ each in its own line. After the word „d“, there is no comma because it is the last value in the array X.
Before we print the curly bracket that denotes the end of array X, we need to decrease the indentation for 2. After the curly bracket, we print the comma and a new line and the continue printing the values from the main array.