Third word

You have a word, and you can change the order of its letters however you
like. Of all the possible results, which would be the third, in
alphabetical order?

Input

Input consists of several non-empty words s, each with at most 10⁵
lowercase letters.

Output

For every s, among all the possible reorderings of its letters, print
the third in alphabetical order. If there is no such third word, print
“NO”.

Problem information

Author: Salvador Roura
Event: Vint-i-quatrè Concurs de Programació de la UPC - Semifinal
Date: 2026-06-18

Generation: 2026-06-10T18:09:21.411Z

© Jutge.org, 2006–2026.
https://jutge.org
