Educational round 114 A (codeforce writeup)

--

The problem is described below

the problem

My first try was trying to generate all combinations and filter them ( complete search )

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.

the pattern

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.

accepted answer

The time complexity is O(n²) for each test case which is good enough for n = 50.

--

--

No responses yet