RGB Substring (hard version)

Problem Name:
RGB Substring (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: