String game (GAME THEORY)

please give me the approach to be used in this question
an elaborate one with reason behind every step
i have given more than 6 hrs to this problem and still am no-where close to solving this problem
PLEASE HELP ME

question link:
https://hack.codingblocks.com/contests/c/668/593

MENTORS / TA’S
PLEASE HELP ME
I AM NOT ABLE TO SOLVE THIS QN

please help me in this question bhaiya
@Saurabh-Kumar-1331476656958199

did you understand the Q properly ?

This game can be easily reduced to the game of nim. Each segment of consecutive same letters(for eg. “aaa”), can be considered as a pile of game of nim. For a single string, we can just take xor of the piles we defined earlier.

Now, let the two arrays, pre[] and ,suff[] be the arrays, such that,

pre[i] xor value for the substring . S[1…i]

suff[i] xor value for the substring . S[n…i]

Now if the second kid breaks the string after ith position in a string, then the xor value of the game will be:-

pre[i]^suf[i+1]. Traverse through all i’s, and if there exists any i,such that pre[i]^suf[i+1] = 0, the answer is Yes, otherwise No.

if you have any doubt in this approach fell free to tag me…

@Saurabh-Kumar-1331476656958199
i understood that each part with same consecutive letters in a substring is an individual game of NIM, but how is the following case working?
e.g. bbaaabbb
the array you are talking about will be 2 3 3 which are individual nim games
but after removing aaa string becomes 5 Bs
(question says the strings are joined after removing a segment)
how is this considered in your solution??

is a puzzle game where you have to use strings to guide either your ball or square to the right places . There are different strings that move in different ways. The yellow string can be moved freely, this is great Slope unblocked for picking up objects and moving them to another place. The major components that help in analyzing a data driven decision making problem include: The set of options or choices available. The set of outcomes based on these choices