Preparando MOJI

Erasing Substrings

1000ms 262144K

Description:

You are given a string s, initially consisting of n lowercase Latin letters. After that, you perform k operations with it, where . During i-th operation you must erase some substring of length exactly 2i - 1 from s.

Print the lexicographically minimal string you may obtain after performing k such operations.

Input:

The only line contains one string s consisting of n lowercase Latin letters (1 ≤ n ≤ 5000).

Output:

Print the lexicographically minimal string you may obtain after performing k operations.

Sample Input:

adcbca

Sample Output:

aba

Sample Input:

abacabadabacaba

Sample Output:

aabacaba

Note:

Possible operations in examples:

  1. adcbca adcba aba;
  2. abacabadabacaba abcabadabacaba aabadabacaba aabacaba.

Informação

Codeforces

Provedor Codeforces

Código CF938F

Tags

bitmasksdpgreedy

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:32:09

Relacionados

Nada ainda