P29216 [洛谷] [COCI2015-2016#7] Nizovi
普及
题目描述

Problem Description

In a certain programming language, arrays are defined as follows:

  • The beginning and end of an array are denoted by curly braces ({ and }).
  • Inside the curly braces, there are several (possibly zero) elements separated by commas (there is no comma after the last element).
  • Each element can be a word (a string consisting of lowercase letters) or an array.
  • Some valid arrays: {}, {a,b,c}, {abc,znj,{novi,niz},pozz}.

You need to format the array in a way that makes the program more aesthetically pleasing:

  • Start a new line when encountering a word or a curly brace.
  • Place commas directly after an array element.
  • Increase the indentation by 2 spaces every time you encounter a {.
  • Decrease the indentation by 2 spaces every time you encounter a }.

Given an array, output its format in the specified style.

Input Format

A string \( S \), representing the given array.

Output Format

The array in the specified format.

Sample Input and Output

Sample Input #1

{abc,ono,sto}

Sample Output #1

{
  abc,
  ono,
  sto
}

Sample Input #2

{}

Sample Output #2

{
}

Sample Input #3

{znakovi}

Sample Output #3

{
  znakovi
}

Sample Input #4

{a,b,{c,d},e,{}}

Sample Output #4

{
  a,
  b,
  {
    c,
    d
  },
  e,
  {
  }
}

Notes

Data Range and Constraints

  • For 50% of the test cases, the elements only contain words.
  • For 100% of the test cases, \( 1 \leq |S| \leq 1500 \).

Hints and Notes

The checker is from the Testlib library, see the attachment.

This problem is translated from COCI 2015-2016 #7 Task 1 Nizovi.

The score for this problem is set according to the original COCI, with a maximum of 50 points.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
{abc,ono,sto}
样例输出
{ abc, ono, sto }