Educational round 114 A (codeforce writeup)
Sep 20, 2021
The problem is described below
My first try was trying to generate all combinations and filter them ( complete search )
The time complexity is O( 2^n * n ) which is too big for n = 50. We could use memorization which still gives the same time complexity, so it doesn’t help at all.
But we can extract the pattern from each test case as shown below.
We just have to generate char[50][100], and fill all of them. Then we could extract all the answer from n = 1–50 from that array as shown below.
The time complexity is O(n²) for each test case which is good enough for n = 50.