#P1061. [NOIP 2006 普及组] Jam 的计数法

[NOIP 2006 普及组] Jam 的计数法

Description

Jam is an eccentric scientist who likes to be unconventional. He does not count with Arabic numerals, but with lowercase English letters. He believes this makes the world more colorful.

In his counting system, every number has the same length (uses the same number of letters). The English letters keep their original order, and a letter earlier in the alphabet is smaller than a letter later in the alphabet. We call such “numbers” Jam numbers. In a Jam number, all letters are distinct and strictly increasing from left to right. Each time, Jam also specifies the range of letters to use; for example, from 2102\sim 10 means only the letters b,c,d,e,f,g,h,i,j{b,c,d,e,f,g,h,i,j} can be used. If the length is further specified to be 55, then the number immediately following the Jam number bdfij\texttt{bdfij} should be bdghi\texttt{bdghi} (if we denote the Jam numbers bdfij\texttt{bdfij} and bdghi\texttt{bdghi} by UU and VV in order, then U<VU<V, and there is no Jam number PP such that U<P<VU<P<V).

Your task: Given a Jam number read from the file, output in order the next 55 Jam numbers. If there are fewer than 55 Jam numbers after it, output as many as exist.

Input Format

There are 22 lines.

The first line contains 33 positive integers s,t,ws, t, w, separated by a space.

(Here, ss is the index of the smallest letter used, tt is the index of the largest letter used, and ww is the length of the number. These 33 numbers satisfy 1s<t26,2wts1\le s<t\le 26,2\le w\le t-s.)

The second line is a string with ww lowercase letters, which is a valid Jam number.

The given testdata is correct; no validation is needed.

Output Format

Output up to 55 lines: the next 55 Jam numbers after the input Jam number in order. If there are fewer than 55 Jam numbers after it, output as many as exist. Print exactly one Jam number per line, each being a string of ww lowercase letters, with no extra spaces.

2 10 5
bdfij

bdghi
bdghj
bdgij
bdhij
befgh

Hint

NOIP 2006 Junior Problem 3.

Translated by ChatGPT 5