WAGE - Wood, Axe and Grass
Danny has created a new civilization on a 2D grid. At the outset each grid location may be occupied by one of three life forms: Woods, Axe, or Grass. Each day, differing life forms occupying horizontally or vertically adjacent grid locations wage war. In each war, Woods always defeat Axe, Axe always defeat Grass, and Grass always defeat Woods. At the end of the day, the winner expands its territory to include the loser's grid position. The loser vacates the position. Determine the territory occupied by each life form after n days.
Input
The first line of input contains t, the number of test cases. Each test case begins with three integers not greater than 100: r and c, the number of rows and columns in the grid, and n. The grid is represented by the r lines that follow, each with c characters. Each character in the grid is W, A, or G, indicating that it is occupied by Woods, Axe, or Grass respectively.
Output
For each test case, print the grid as it appears at the end of the nth day.
Example
Input: 2 3 3 1 WWW WAW WWW 3 4 2 WAGW AGWA GWAG Output: WWW WWW WWW WWWA WWAG WAGW
hide comments
nadstratosfer:
2019-03-02 14:59:45
Print no blanklines between cases as opposed to what samples imply. Kudos to Zukow for explaining the amiguous statement, I'm here to solve problems not guess my way through riddles. Last edit: 2019-03-02 15:06:53 |
|
photon_:
2017-11-27 19:55:00
easy implementation. Got AC with only 34 lines of code C++ :) |
|
Siddharth Singh:
2016-07-09 09:04:27
Nice Problem.
|
|
xpshekhar:
2015-12-25 00:13:46
those who found difficult to understand
|
|
:.Mohib.::
2015-06-08 14:31:19
Easy one ;) |
|
(^_^):
2013-04-03 09:12:30
Accepted on first try. Simple question below comments really helped alot |
|
张翼德:
2012-12-19 05:32:12
simple ad-hoc :/ |
|
Artur Laskowski:
2012-10-29 21:42:13
Could anybody help my with my program?
|
|
Prakhar Jain:
2011-12-12 12:52:00
so much time wasted due to silly mistakes
|
|
:D:
2011-10-02 10:43:34
No, that's incorrect.
|
Added by: | Infinity |
Date: | 2011-03-21 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ADA95 ASM32 ASM64 BASH CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO ICON ICK LUA NEM NICE OCAML PIKE PRLG-swi SCM guile SCM qobi ST TCL WHITESPACE |
Resource: | Own |