AlphaWord
SRM 124 · 2002-12-12 · by dgoodman
Problem Statement
Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet.
Create a class Alphabet that contains the method firstAlpha that takes the
decree as input and returns the new alphabet as a
Constraints
- decree contains between 1 and 25 characters, inclusive.
- Each character in decree is the uppercase letter 'B' or 'A'.
"BAA" Returns: "adcb"
'a' Before 'b', 'b' After 'c', and 'c' After 'd' have been decreed, so possibilities are "adcb", "dacb", "dcab".
"AAAA" Returns: "edcba"
"edcba" is the only alphabet that conforms.
"BBAA" Returns: "abedc"
all the alphabets that satisfy this are: "edabc", "eadbc", "aedbc", "eabdc", "aebdc", and "abedc". Of these, the first is "abedc".
"BABAAA" Returns: "acbgfed"
"A" Returns: "ba"
Submissions are judged against all 25 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class AlphaWord with a public method string firstAlpha(string decree) · 25 test cases · 2 s / 256 MB per case