1234F - Yet Another Substring Reverse
Hello my friends.
I am having trouble with the problem 1234F - Yet Another Substring Reverse.
It seems my approach is not optimal so my program can only be accepted with small trials. I also consulted my friends but to no avail. Can you come up with a way to solve this problem?
Thank you very much.