794C: Naming Company
Consider the final string will have 2/n chars from each person. Obviously, Oleg will take the smallest n/2 chars, and Igor biggest n/2 chars from their own sets, since we can improve the answer from each’s perspective otherwise.
When O is playing
if current O’s smallest < I’s largest, O will need to fill the left most unoccupied with its own smallest, otherwise I will fill it with largest => not optimal
if current O’s smallest >= I’s largest, O will need to fill the right most unoccupied with O’s largest
When I is playing
if current O’s smallest < I’s largest, I’s largest goes left most
if current O’s smallest >= I’s largest, I’s smallest goes to right most
What I did wrong
The tie breaker case, the player should not occupy the the leftmost position with their own char, instead, they should try to force the opponent to take that position, while preserve their best candidate for the next round!!!