시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 4 | 3 | 3 | 75.000% |
As you might remember from your first years in school, the human race invented beer brewing at least about 7000 years ago. The total amount of beer consumed from those times must be monumental and surely the rate of consumption is not going to shrink in the coming millennia.
To celebrate these facts, we invite you to implement a game, seemingly unrelated to beer brewing. It is quite possible, however, that after a successful implementation you might feel a little dizzy, just as if you have had a little bit more than your daily dose of beer...
The game is played on a rectangular M × N grid consisting of square tiles of different types.
Animals and food
There is some number of animals on the grid, each animal occupies exactly one tile.
Grass grows, sheep eat grass, wolves eat sheep, and both wolves and sheep can die of starvation.
Turns and animal actions
Each turn consists of actions in the following order:
Types of tiles and their changes
There are three types of tiles. The type of a tile may be changed in the course of the game.
First line of the input contains three integers T, N and M (1 ≤ T ≤ 100, 1 ≤ M, N ≤ 20), where T is the number of turns, M is the number of rows and N is the number of columns of the grid. The following M lines contain N characters each. Characters denote the types of tiles:
.
(dot character) denotes a Soil tileS
denotes a Soil tile with a sheep on itW
denotes a Soil tile with a wolf on itOutput M lines each containing N characters describing the state of the grid after the end of the T-th turn. If there is an animal on a tile, output:
W
for a tile with a wolf on itS
for a tile with a sheep on itOtherwise, output:
*
for a Soil with carcass tile#
for a Soil with grass tile.
(dot character) for a Soil tile6 6 5 ..S.. ..... .S... ..... ....W .S...
##S## ##### ##### #.### W*.## #S.##
14 3 3 S.. W.. ...
.## #*# S##
2 3 1 S . .
. . S
3 3 1 S . .
S # #
4 3 1 S . .
# S #
5 3 1 S . .
# . S