Kirk and a Binary String (hard version)

Problem Name:
Kirk and a Binary String (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: