CF797C.Minimal string

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Petya recieved a gift of a string ss with length up to 10510^{5} characters for his birthday. He took two more empty strings tt and uu and decided to play a game. This game has two possible moves:

  • Extract the first character of ss and append tt with this character.
  • Extract the last character of tt and append uu with this character.

Petya wants to get strings ss and tt empty and string uu lexicographically minimal.

You should write a program that will help Petya win the game.

输入格式

First line contains non-empty string ss ( 1<=s<=1051<=|s|<=10^{5} ), consisting of lowercase English letters.

输出格式

Print resulting string uu .

输入输出样例

  • 输入#1

    cab
    

    输出#1

    abc
    
  • 输入#2

    acdb
    

    输出#2

    abdc
    
首页