Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Since at each query, only one element is being recolored, we just need to focus on its neighbors.
If an element that is changed on the i-th query had the same color as its right element answer decreases by 1. Similarly contributes its left element too.
After changing the color, if the element has the same color as its right element answer increases by 1. Similarly contributes its left element too.