Game with Coins#1446

Game with Coins

1 Sekunde
64 Megabyte
Mittel

In the coin game, a horizontal strip is divided into identical square cells. Initially, some of these cells contain coins, while others are empty.

Two players, Dmytro and Ivan, take turns making moves, with Dmytro going first. During each turn, a player can perform the following actions:

  1. Choose any coin that has at least one empty cell to its right.

  2. Move the selected coin to any empty cell located to its right.

  3. Shift all coins that lie between the selected coin's original and new positions exactly one cell to the left.

An example move is shown in the following image:

A coin is represented by the symbol , and an empty cell by the symbol . Thus, the state of the strip can be described as a string of characters. For the example above, the strip's state before the move is represented by the string , and after the move, it becomes .

The player who cannot make a move (i.e., all coins are adjacent to the right edge of the strip during their turn) loses the game. Consequently, the player who made the last move wins.

Assuming both Dmytro and Ivan play optimally, write a program that takes the initial state of the strip and determines the winner of the game.

Eingabe

A string that describes the initial state of the strip.

  1. The string contains between and characters, inclusive.

  2. The string consists only of the characters and .

  3. The string contains at least one .

  4. The string contains at least one .

Ausgabe

Output if Dmytro wins the game, or if Ivan wins.

Beispiele

Beispiel 1

Loading
Loading