#P15704. [2018 KAIST RUN Spring] Yut Nori

[2018 KAIST RUN Spring] Yut Nori

题目描述

Yut Nori (Yut Game) is one of famous played with Yut. Yut Nori is played with 4 yuts, one Yut board, and 8 tokens, 4 for each two team. Yut board has 29 stations. Each station has its own name. (Figure 1)

:::align{center}

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

:::align{center}

Figure 2: possible four routes. :::

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

Turn of each person is as follows:

  • Throw 4 Yut.
  • Determine the number of steps based on Yut.
  • Select the token and walk through the board.

Yut has front-side and back-side. If Yut is thrown, its front-side or back-side is shown. The number of steps is the number of front side. However, if every side is back-side, the number of steps is 5.

The new token starts at cham-moeki (it is not placed actually, but assume the token is placed so), and follows these Yut-gil(route).

Basically, tokens move through the fourth route (Figure 2). For example, if you walk two steps from yut, it goes to duet-do. But in special cases, it goes through first, second, or third route. If it starts from corner (mo, duet-mo, bang, chi-mo, or cham-meoki), it selects faster way to cham-meoki.

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

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

Moreover, if token following the third route starts from bang, then token follows the first route. Walking one step goes to saryeo, two steps goes to anchi.

Tokens moving like these escapes the board after it arrived cham-meoki. (It does not require separate steps) For example, if you walk two steps from nal-geol, it arrives to cham-meoki, and walking one step more makes the token escape.

If you walk three or more steps from nal-geol at once, it also escapes the board.

Until now, this is the game that just throws Yut to escape. However, there are two more rules to make the game more fun.

First rule is, move together. If there are two or more tokens at the same station, moving one of them will move every token.

Second rule is, token catch. If opponents' token is placed at the destination of your token, move all of opponents' token to initial state.

You are given a task for development of Yut Nori. You have to replay the game.

输入格式

The first line of input consists NN. This is the number of the turn.

In iith line of following NN lines, the information of iith turn is given. The information of iith line is given as information of token and yut.

The information of token is given as one character, one of "ABCDabcd". The information of Yut is given as a string with four characters, each character is 'B' for back, and 'F' for front. The information of token and Yut is space-separated.

The tokened are teamed with upper-case and lower-case.

输出格式

Basic Yut board is given as following 32×3232 \times 32 string.:

..----..----..----..----..----..
..    ..    ..    ..    ..    ..
| \                          / |
|  \                        /  |
|   \                      /   |
|    ..                  ..    |
..   ..                  ..   ..
..     \                /     ..
|       \              /       |
|        \            /        |
|         ..        ..         |
|         ..        ..         |
..          \      /          ..
..           \    /           ..
|             \  /             |
|              ..              |
|              ..              |
|             /  \             |
..           /    \           ..
..          /      \          ..
|         ..        ..         |
|         ..        ..         |
|        /            \        |
|       /              \       |
..     /                \     ..
..   ..                  ..   ..
|    ..                  ..    |
|   /                      \   |
|  /                        \  |
| /                          \ |
..    ..    ..    ..    ..    ..
..----..----..----..----..----..

This string consists of “/\.|”, space and newline character. (quote is not included.) This string denotes Yut board, each station is represented as 2×22 \times 2 ‘.’ character. From upper-leftmost character, 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 print whether the token is in this board. You should replace one of ‘.’ character for the token in station.

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

5
A BFBB
B BFFB
C BFFB
D BFFB
b BFFB
..----..----..----..----..----..
..    ..    ..    ..    ..    ..
| \                          / |
|  \                        /  |
|   \                      /   |
|    ..                  ..    |
..   ..                  ..   ..
..     \                /     ..
|       \              /       |
|        \            /        |
|         ..        ..         |
|         ..        ..         |
..          \      /          ..
..           \    /           c.
|             \  /             |
|              ..              |
|              ..              |
|             /  \             |
..           /    \           ..
..          /      \          ..
|         ..        ..         |
|         ..        ..         |
|        /            \        |
|       /              \       |
..     /                \     ..
..   ..                  ..   ..
|    ..                  ..    |
|   /                      \   |
|  /                        \  |
| /                          \ |
..    ..    ..    ..    ..    ..
..----..----..----..----..----..
21
A FFFB
c FBBF
d FBBB
B BBFB
C BFBF
d FFBF
B BFBF
a BBBF
C BBBB
D FBFF
a FFFB
d FBFF
b FFFF
b BBBB
c BFFF
B BBFB
b BBBF
B FFFF
c BBBB
b BBBF
A FFFF
..----..----..----..----..----.B
..    ..    cd    C.    ..    ..
| \                          / |
|  \                        /  |
|   \                      /   |
|    ab                  ..    |
..   ..                  ..   A.
..     \                /     ..
|       \              /       |
|        \            /        |
|         ..        ..         |
|         ..        ..         |
..          \      /          ..
..           \    /           ..
|             \  /             |
|              ..              |
|              ..              |
|             /  \             |
..           /    \           ..
..          /      \          ..
|         ..        ..         |
|         ..        ..         |
|        /            \        |
|       /              \       |
..     /                \     ..
..   ..                  ..   ..
|    ..                  ..    |
|   /                      \   |
|  /                        \  |
| /                          \ |
..    ..    ..    ..    ..    ..
..----..----..----..----..----..

提示

Constraints

  • 1N1001 \leq N \leq 100
  • Every move is valid; escaped token will not be given again at board.