2774 - DS_2023Spring_Lab2 Scoreboard

Time

2023/04/10 18:30:00 2023/04/10 21:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13876 Zuma

13876 - Zuma   

Description

Zuma used to be a popular game in the early 2000s. In the game, a track of colorful beads rolls slowly towards a “hole”. The player has to shoot bead into the track, to attempt to form a group of 3 or more continuous beads with the same color. Once formed, the group will be eliminated, effectively slowing down the advancement of the beads.

In this problem, we will have initially N beads on the track and the colors of beads are red, green and blue. You need to shoot a bead with a given color C after the mth bead (count from the first bead on the track and the index starts from one). The bead will connect three or more beads of the same color on the track (form a string with ≥ 3 beads, called STRING), and do one of the following action depending on the beads’ color:

  • - eliminate
    • happen when the color of STRING is Red
    • action: eliminate STRING
  • - double
    • happen when the color of STRING is Green
    • action: double the count of STRING and move to the end of the beads on the track
  • B - Reverse
    • happen when the color of STRING is Blue
    • action: move STRING to the front of beads on the track and reverse the order of the beads on the track

After the action, the remaining beads on the track will connect together. If there are three or more beads of the same color connected together due to the action, they will form STRINGS again and do the action depending on the beads’ color. After the beads on the track become static, that is, no more chain reactions will happen, the program is ended. Please provide the final order of the beads on the track (starting with the first bead on the track) and the remaining number of beads.

Input

  • The first line (separated by a space), there is a newline at the end.:
    • N: number of the initial beads on the track; 1≤N≤100
    • m: the index of the bead that the shot bead should put after; 1≤m≤100
    • C: the color of the shot bead; C∈{R, G, B}
  • After the first line: a series of R, G, B, representing the color of the beads, separated by \n. There is a newline at the end.

Output

  • The first line: the final order of the beads on the track
    • Starting with the first bead on the track
    • Consisting of a series of R, G, B, separated by a space. (No space at the end)
    • There is a newline at the end.
  • The second line: the remaining number of beads
    • There is a newline at the end.

Sample Input  Download

Sample Output  Download

Tags

linked list 23S_DS game



Discuss