Missing Word (APCS 2024-06 Advanced)
2.0s 256MGiven a sorted alphabet \(A\) of distinct lowercase letters, a length \(L\), and a lowercase string \(S\), find the lexicographically smallest length-\(L\) word over \(A\) that is not a substring of \(S\). Letters may repeat. An answer exists. \(S\) may contain letters outside \(A\).
Input
Three lines contain \(A\), \(L\), and \(S\).
Constraints
\(1\le|A|\le10\), \(1\le L\le8\), \(|A|^L\le600000\), \(L\le|S|\le500000\).
Output
Print the smallest missing word.
Scoring
Each scored test independently awards 5 points, totaling 100. Samples award no points.
- 1: 20% — \(|S|=1000\)
- 2: 80% — No additional restrictions.
Sample Input 1
acm
2
accaamcm
Sample Output 1
ma
Sample Input 2
dp
3
dddppdpd
Sample Output 2
pdd
Source
Log in to write and submit code.
Log in