#P8719. Bubble Sort Swap Count String

    ID: 21883 Type: Default 1000ms 256MiB

Bubble Sort Swap Count String

Bubble Sort Swap Count String

Little Lan has been studying several sorting algorithms, and bubble sort impressed him most. In bubble sort only two adjacent elements can be swapped, and it turns out that when sorting the characters of a string by only swapping adjacent characters, the total number of swaps performed by bubble sort is minimum among all possible sorting schemes. In other words, the number of swaps equals the number of inversions in the string, i.e. \[ \textrm{swaps} = \sum_{0\le i<jS[j]} \] where n is the length of the string.

Little Lan’s lucky number is \(V\). He wishes to find a string containing only lowercase English letters such that if one performs bubble sort on it (only swapping adjacent characters), the total number of swaps will be exactly \(V\). If there exist several such strings, output the shortest one; if there are still more than one, output the lexicographically smallest one. Note that characters in the string may be repeated.

inputFormat

The input consists of a single integer \(V\) representing the target number of bubble sort swaps (inversions).

outputFormat

Output a string that meets the criteria.

sample

0
a