#P8032. [COCI 2015/2016 #7] Nizovi
[COCI 2015/2016 #7] Nizovi
Problem Description
Arrays in a programming language are defined as follows:
- The beginning and end of an array are marked with curly braces ( and ), respectively.
- Inside each pair of braces, there are several (possibly ) comma-separated elements (there is no comma after the last element of each array).
- Each element can be either a word (a string consisting of lowercase letters) or another array.
- Some valid arrays are: $\texttt {\{\}}, \texttt{\{a,b,c\}}, \texttt{\{abc,znj,\{novi,niz\},pozz\}}$.
You need to apply the following formatting style to make the program look nicer:
- Start a new line whenever you encounter a word or a curly brace.
- A comma should be placed directly after an array element.
- Every time you encounter a , increase the indentation by spaces.
- Every time you encounter a , decrease the indentation by spaces.
Given an array, output it in the above formatting style.
Input Format
A string representing the given array.
Output Format
The array formatted in the required style.
{abc,ono,sto}
{
abc,
ono,
sto
}
{}
{
}
{znakovi}
{
znakovi
}
{a,b,{c,d},e,{}}
{
a,
b,
{
c,
d
},
e,
{
}
}
Hint
Constraints
- For of the testdata, elements contain only words.
- For of the testdata, .
Hints and Notes
The checker is from the Testlib library, see the attachment.
Translated from COCI 2015-2016 #7 Task 1 Nizovi.
The score for this problem follows the original COCI settings, with a full score of .
Translated by ChatGPT 5