CF645E Intellectual Inquiry
Description
After getting kicked out of her reporting job for not knowing the alphabet, Bessie has decided to attend school at the Fillet and Eggs Eater Academy. She has been making good progress with her studies and now knows the first $ k $ English letters.
Each morning, Bessie travels to school along a sidewalk consisting of $ m+n $ tiles. In order to help Bessie review, Mr. Moozing has labeled each of the first $ m $ sidewalk tiles with one of the first $ k $ lowercase English letters, spelling out a string $ t $ . Mr. Moozing, impressed by Bessie's extensive knowledge of farm animals, plans to let her finish labeling the last $ n $ tiles of the sidewalk by herself.
Consider the resulting string $ s $ ( $ |s|=m+n $ ) consisting of letters labeled on tiles in order from home to school. For any sequence of indices $ p_{1}
Input Format
N/A
Output Format
N/A
Explanation/Hint
In the first sample, the optimal labeling gives $ 8 $ different subsequences: "" (the empty string), "a", "c", "b", "ac", "ab", "cb", and "acb".
In the second sample, the entire sidewalk is already labeled. The are $ 10 $ possible different subsequences: "" (the empty string), "a", "b", "aa", "ab", "ba", "aaa", "aab", "aba", and "aaba". Note that some strings, including "aa", can be obtained with multiple sequences of tiles, but are only counted once.