Codeforces Round #585 (Div. 2) C. Swap Letters

Reproduced the thoughts of the boss:

Link to this article: https://blog.csdn.net/Cassie_zkq/article/details/100884622

The idea is very simple to understand:

This is a greedy problem. In fact, the optimal solution is aa. At this time, the transformation is only one step, cnt1+1, so we should look for such a logarithm in the two-line string

                                                           bb

But if there are an odd number of such pairs, there must be ab, and the transformation at this time must have two cnt2+1

                                                                             ba

Perform statistics on the two lines of strings (using dynamic arrays), and count the logarithms and their positions.

Guess you like

Origin blog.csdn.net/weixin_44067773/article/details/101191515
Recommended