EternalWisdom's blog

By EternalWisdom, history, 5 months ago, In English

This is the Problem A from the latest ARC, ARC 180 Problem A ABA and BAB The editorial talks about some parity inversion technique. In competitive programming, a well-known technique is using parity to perform inversions. Let’s apply it to this problem.

I understand that the technique is not required for solving the problem and It is possible to get the result by just observing the lengths of alternating characters and multiplying them together. However, I was interested in the Proof of the Claim given in the editorial. The claim is- Specifically, let’s invert the characters A and B only at even positions in the input string. __ Then, the two available operations become the following: __ AAA → A BBB → B With this transformation, the solution becomes almost obvious. For a contiguous segment of A or B, as long as its length does not become zero, we can reduce the length by 2 each time.

The solution after the the transformation is obvious. But how can you prove that the transformation preserves the result of the problem.

Any Help is appreciated.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it