#P2628. Board Game Bonus and Penalty Simulation

    ID: 15896 Type: Default 1000ms 256MiB

Board Game Bonus and Penalty Simulation

Board Game Bonus and Penalty Simulation

You are given a board represented by a string of characters. Each character represents a step on the board. A game token starts at the first character of the board. You will also be given a sequence of dice rolls. For each dice roll, the token moves the number of steps equal to the dice value. However, after each move, there may be a bonus or penalty based on the symbol where the token lands:

  • Bonus (Forward Movement): If the token lands on the character > and the next two characters (immediately following) are also > (i.e. the contiguous sequence starting at the landing position has at least 3 consecutive > characters), then the token receives a bonus. The bonus allows the token to move forward one step at a time as long as the next character is >. The token stops when the next character is not >.
  • Penalty (Backward Movement): If the token lands on the character * and the next two characters are also * (i.e. the contiguous sequence starting at the landing position has at least 3 consecutive * characters), then the token suffers a penalty. The penalty forces the token to move backwards by k steps, where k is the count of consecutive * starting from that position. After a bonus or penalty, if the token lands on another special symbol, no further bonus or penalty is applied in that turn.

Additionally, if a move causes the token to go past the right end of the board, the token stops at the last character. Similarly, if it goes past the left end, it stops at the first character.

After processing all dice rolls, output two numbers separated by a space: the step number (1-indexed) where the token ended up, and the number of steps remaining to reach the final character of the board.

Note: Use \(\LaTeX\) format for any formulas if needed.

inputFormat

The input consists of multiple lines:

  1. The first line contains the board string.
  2. The second line contains an integer n denoting the number of dice rolls.
  3. The third line contains n space-separated integers representing the dice roll values.

outputFormat

Output two integers separated by a space: the final step (1-indexed position on the board where the token stops) and the number of steps remaining to reach the end of the board.

sample

ABCDE
2
2 3
5 0