CCC '19 J5 - Rule of Three
Submit solution
Points:
1
Time limit:
1.0s
Memory limit:
1G
Problem type
Allowed languages
C++, Python
Sample Input
AA AB
AB BB
B AA
4 AB AAABPossible Output for Sample Input
2 1 BB
3 1 AAB
3 3 AAAA
1 3 AAABExplanation of Output for Sample Input
This is the example outlined in the problem description. Note that the following is another possible valid substitution sequence:
2 1 BB
3 2 BAA
1 2 BAB
3 1 AAABSpecifically, showing the substitutions in bold , we get
\[\displaystyle \textbf{AB} \to B\textbf{B} \to B\textbf{AA} \to \textbf{B}AB \to AAAB.\]
Comments