Please read the new rule regarding the restriction on the use of AI tools. ×

ARC180 Proof of Problem A Parity Inversion

Revision en1, by EternalWisdom, 2024-07-11 15:38:37

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.

Tags atcoder, permutations, inversions, string, parity

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English EternalWisdom 2024-07-11 15:38:37 1208 Initial revision (published)