Promising String (hard version)

Problem Name:
Promising String (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: