405147: GYM101806 Y Yut Nori

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Y. Yut Noritime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Yut Nori (Yut Game) is one of the most famous board game which uses Yuts. Yut Nori consists of 4 Yuts, one Yut board, and 8 tokens: 4 for each team. The Yut board has 29 stations. Each station has its own name. (Figure 1)

Figure 1: Yut board. There is name for each stations.

Figure 2: possible four routes.

The goal of the game is starting from cham-meoki, to walk through the board and return to cham-meoki and escape.

At the beginning of each turn, one person:

  • throws 4 Yuts;
  • determines the number of steps to progress based on the Yuts;
  • choose a token and walks through the board.

Each Yut has a front-side and a back-side. When a Yut is thrown, its front-side or back-side is shown. The number of steps is the number of front-sides, except when every side is a back-side, the number of steps is 5.

Each token starts at cham-meoki (it is not placed actually, but it is assumed that the token is placed there), and follows the Yut-gil (route).

Basically, tokens move through the fourth route (Figure 2). For example, if a token walks two steps from yut, it reaches duet-do. But in special cases, they go through the first, second, or third route. If a token starts from corner (mo, duet-mo, bang, chi-mo, or cham-meoki), it chooses the faster way to cham-meoki.

More formally, if a token starts moving at mo, the route changes to the third one. For example, if it walks one step from mo, it goes to mo-do; two steps from mo, it goes to mo-gae. If it walks one step twice from yut, it goes to mo-do, but if you walk two steps from yut in one turn, it goes to duet-do.

Also, if it start from duet-mo, it follows the second route, so walking one step leads to duet-modo, while walking two steps leads to duet-mogae.

Moreover, if a token following the third route starts from bang, then it starts to follow the first route. Walking one step leads to saryeo; two steps, anchi.

Moving through these routes, a token escapes the board after it returns to cham-meoki then takes another step. This does not require separate turns. For example, if you walk two steps from nal-yut, it arrives at cham-meoki then escapes. Similarly, taking 3, 4, or 5 steps from nal-geol counts as an escape.

Until now, this is just a game about throwing Yuts to escape. To make the game more fun, there are two more rules.

The first rule is moving together. If there are two or more tokens possessed by the same player at the same station, moving just one of them will cause all other tokens to move together.

The second rule is catching a token. If opponents' tokens are placed at the next destination of your token, all the opponents' tokens at that station move to the initial state.

You are given a task to develop the Yut Nori game. Given a series of turns, output the final state of the board.

Input

The first line of the input consists of N, the number of the turns. (1 ≤ N ≤ 100)

In the i-th line of following N lines, the information of the i-th turn. It is represented by a token and Yuts.

The information for the token is given as one character, one of "ABCDabcd". The information for Yuts is given as a string with four characters, each character being either 'B' for back-sides, or 'F' for front-sides. Two pieces of information are space-separated.

Upper-case letters represent tokens in one team; lower-case letters represent tokens in the other team.

Every move is valid; escaped token will not be given again at board.

Output

The basic Yut board is given as the following 32 × 32 string. By the technical difficulty, it is posted as an attachment, with sample input/output. (If you have better idea, please let us know.)

This string consists of "/\.|",space, and newline character. (quotation marks are not included.) This string denotes the Yut board, and each station is represented as 2 × 2 '.' characters. From the upper-leftmost character, the stations are duet-mo, duet-yut, duet-geol, duet-gae, duet-do, mo, duet-modo, mo-do, chi-do, yut- duet-mogae, mo-gae, chi-gae, geol, bang, chi-geol, gae, sok-yut, saryeo, chi-yut, do, sok-mo, anchi, chi-mo, nal-do, nal-gae, nal-geol, nalyut, and cham-meoki, read row major order.

You should indicate where each token is located. Replace one of the '.' characters with the token in the station.

A or a should replace the upper-left '.', B or b should replace the upper-right '.', C or c should replace the lower-left '.', and D or d should replace the lower-right '.' of the station.

File URL: http://run.kaist.ac.kr/contest18s/Y.zip

Basic Yut board: yut_board.txt

Sample Input 1: samp1.in, samp1.out

Sample Input 2: samp2.in, samp2.out

加入题单

算法标签: