Company: Toast_27april
Difficulty: medium
Binary string game Problem Description Alice is playing a game starting with a binary string B of length 3 N . She repeatedly performs the following operations: Partition the current string into contiguous groups of 3 characters each. From each group, she picks the majority character (0 or 1) to form a new string. For a binary string B = B 1 B 2 ...B 3 N of length 3 N , we define an operation to obtain a binary string C = C 1 C 2 ...C 3 (N-1) of length 3 (N-1) . This means that for i = 1, 2, ..., 3 (N-1) , let C i be the value that appears most frequently among B 3i-2 , B 3i-1 , and B 3i . This process continues until Alice is left with a single character. You are provided with: An integer n such that the starting string length is 3 N . A final character (0 or 1) that represents the last remaining character after all the operations are done. You need to determine how many different binary strings (modulo 10 9 +7) of length 3 N would ultimately yield the final character after performing