CF125B.Simple XML

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's define a string as an opening tag, where xx is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type , where xx is the same letter.

Tegs can be nested into each other: in this case one opening and closing tag pair is located inside another pair.

Let's define the notion of a XML-text:

  • an empty string is a XML-text
  • if ss is a XML-text, then ss' =+ ss + also is a XML-text, where aa is any small Latin letter
  • if s1s_{1} , s2s_{2} are XML-texts, then s1s_{1} + s2s_{2} also is a XML-text

You are given a XML-text (it is guaranteed that the text is valid), your task is to print in the following form:

  • each tag (opening and closing) is located on a single line
  • print before the tag 2h2*h spaces, where hh is the level of the tag's nestedness.

输入格式

The input data consists on the only non-empty string — the XML-text, its length does not exceed 1000 characters. It is guaranteed that the text is valid. The text contains no spaces.

输出格式

Print the given XML-text according to the above-given rules.

输入输出样例

  • 输入#1

    <a><b><c></c></b></a>
    

    输出#1

    <a>
      <b>
        <c>
        </c>
      </b>
    </a>
    
  • 输入#2

    <a><b></b><d><c></c></d></a>
    

    输出#2

    <a>
      <b>
      </b>
      <d>
        <c>
        </c>
      </d>
    </a>
    
首页