#P16147. [ICPC 2017 NAIPC] Incremental Double Free Strings
[ICPC 2017 NAIPC] Incremental Double Free Strings
题目描述
A string is called double free if no two adjacent letters are the same.
A string is called -incremental if for all values of in the range , there exists exactly one character with occurrences, and the string’s length is . For example, if , then a 3-incremental string should have one character appear once, another twice, another three times, in any order, for a total string length of .
A string is both -incremental and double free if it meets both these criteria. Now consider examining all such strings of lowercase letters for a given in alphabetical order. Consider the following examples.
: aba, aca, ada, , aya, aza, bab, bcb, bdb, , zxz, zyz
: ababac, ababad, , ababay, ababaz, ababca, , zyzyzx
What is the string in an alphabetized list of all -incremental, double free strings?
输入格式
Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. There will be exactly one line of input. It will contain two integers, and (), which is asking for the string in the alphabetically sorted list of all -incremental, double free strings.
输出格式
Output the -incremental, double free string in the alphabetized list. If no such string exists, output .
2 650
zyz
2 651
-1
5 12345678901234
yuzczuyuyuzuyci