National Olympiad in Informatics, China, 2012
XiaoXi has recently been addicted to the popular iOS game Triple Town. Outside of just playing, XiaoXi has also been thinking about how to obtain higher scores in this game.
As depicted in figure 1, the game takes place on an

Figure 1.
After a player has built a tile on an empty square, a reaction may
take place. The condition for a reaction to form is: starting from the
current square, if the total number of connected squares which has the
same level is greater than or equal to

Figure 2.
Note: in the process of merging tiles, chain reactions may occur. This is depicted below in figure 3.

Figure 3.
The scoring of the game depends on the tiles and their levels, as built by the player or produced by reactions. The score distribution for the different leveled tiles are as follows:
Tile Level | |||||||||
---|---|---|---|---|---|---|---|---|---|
Score Value |
Take the two scenarios depicted above for example. In figure 2, an
To reduce the difficulty of the game, two different tools respectively
called "stars" and "bombs" were introduced. At the start of the game,
the player is given
Stars | A star may be placed on any empty square. When a star is placed, it will automatically transform into a tile capable of invoking the highest possible level of reaction. However, when no reactions may be formed at this location, the star will automatically transform into an |
---|---|
Bombs | A bomb may be placed on any square that's already occupied by a tile. When a bomb is placed, the tile currently at that square will be destroyed and it will be reverted back to an empty space. When using a bomb, half of the value of the destroyed tile will be deducted from the player's score (i.e. a negative score will be incurred). |
In the process of the game, the player must build tiles in the given fixed sequence, and may use these tools at any time. The objective of the game is to, through appropriate build operations, obtain the highest score possible.
To help students better understand this game, XiaoXi has also written a very simple demo program that is available to you for experimentation.
Input Specification
There are tritown1.in
~ tritown10.in
that will be
given to your program (through standard input). They can be downloaded
here for you to study:
tritown.zip
Line tritowni.in
will have
Line
Line
The following .
represents an empty
space, while a number between
The following line will contain a single integer
The last line will contain
Output Specification
Every line should consist of a player command in one of the
Command | Meaning |
---|---|
PUT x y |
Place the next tile in the build sequence on the empty space at row |
STAR x y |
Place a star on the empty space at row |
BOMBER x y |
Place a bomb at row |
END |
Game over. Count the current score. |
Sample Input
0
2 3
1 1
..1
221
2
1 3
Sample Output
PUT 1 2
PUT 1 1
STAR 2 1
END
Explanation
The first move scores
The second move scores
The third move scores
The total score of the game is
Scoring
For each test case, we have set
Score | Condition |
---|---|
If multiple conditions are satisfied, then the condition that yields the highest score will be taken.
Experimentation
We supply a tool tritown_check.py for you to test whether your solutions are accepted. The usage for this program is:
tritown_check.py <input-file> <output-file>
When you execute tritown_check.py
, the program will process your
supplied input and output files and print the results to standard
output. Possible results of the execution include:
Abnormal termination
: An unknown error occurred.Input/Output File Does Not Exist!
: We cannot load your input or output file.Output Invalid!
: There is an error with your output file. A general error message may now be included.Correct! Your score is x
: Your output is acceptable. The amount of points obtained in the game by your solution strategy is .
Problem translated to English by .
Comments