Palindrome Game Hard

This is Codeforces 1527B2, the hard version of Palindrome Game. Alice and Bob play a game on a binary string s of length n that contains at least one '0'.

Alice moves first, then the players alternate. On a turn a player may do exactly one of the following:

  • Choose any '0' and flip it to '1'. This move costs the player 1 dollar.
  • Reverse the whole string for free. This move is allowed only when the current string is not a palindrome and the previous move was not a reversal.

The game ends when every character is '1'. The player who spent fewer dollars wins, and if both spent the same amount the game is a draw.

Both players play optimally. Return "ALICE" if Alice wins, "BOB" if Bob wins, or "DRAW" if neither can force a win.

Examples
Input: "110"
Output: "ALICE"
Hints

Palindrome Game Hard

This is Codeforces 1527B2, the hard version of Palindrome Game. Alice and Bob play a game on a binary string `s` of length `n` that contains at least one `'0'`.