You have a circular ring of n two-sided balls. One side is white (W), the other is black (B). You are also given a list of marks (0-indexed positions on the ring).
Each call to step() increments an internal step counter s by 1, then for every x in marks, flips the ball at position (x + s) mod n.
Implement a class supporting:
step() -> None: perform one step (as described above).getBlack() -> int: return the count of black balls right now (O(1)).getWhite() -> int: return the count of white balls right now (O(1)).jump(k) -> None: equivalent to calling step() exactly k times. Should be faster than O(k * len(marks)) when k is large.Initial state: all balls white, step counter = 0.
Example: ` n = 5, marks = [1, 3] state: [W, W, W, W, W]
step(): s=1, flip (1+1)%5=2 and (3+1)%5=4 -> [W, W, B, W, B] step(): s=2, flip (1+2)%5=3 and (3+2)%5=0 -> [B, W, B, B, B] step(): s=3, flip (1+3)%5=4 and (3+3)%5=1 -> [B, B, B, B, W]
getBlack() -> 4 getWhite() -> 1 `
Tip for jump(k) optimization: any block of n consecutive steps flips every position exactly len(marks) times. So n consecutive steps either leave the ring unchanged (if len(marks) is even) or flip every position (if len(marks) is odd). Use this to handle floor(k / n) full cycles in O(n), then apply the remaining k mod n steps the normal way.